Browse Source

Add files via upload

wibyweb 1 năm trước cách đây
mục cha
commit
a72ff77e9d
2 tập tin đã thay đổi với 46 bổ sung43 xóa
  1. 22 21
      go/core/1core.go
  2. 24 22
      go/core/core.go

+ 22 - 21
go/core/1core.go

@@ -262,6 +262,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
 		queryNoQuotesOrFlags := queryNoQuotes
 		queryNoQuotesOrFlags := queryNoQuotes
 		requiredword := ""
 		requiredword := ""
 		flags := ""
 		flags := ""
+		flagssetbyuser := 0
+		wordlen := 0
+		numRequiredWords := 0
 		//queryNoFlags := ""
 		//queryNoFlags := ""
 		//first remove any flags inside var queryNoQuotes, also grab any required words (+ prefix)
 		//first remove any flags inside var queryNoQuotes, also grab any required words (+ prefix)
 		if strings.Contains(queryNoQuotes, "-") || strings.Contains(queryNoQuotes, "+") {
 		if strings.Contains(queryNoQuotes, "-") || strings.Contains(queryNoQuotes, "+") {
@@ -278,6 +281,10 @@ func handler(w http.ResponseWriter, r *http.Request) {
 				}
 				}
 				if i > 0 && strings.HasPrefix(wordNoFlags, "-") == true || strings.HasPrefix(wordNoFlags, "+") == true {
 				if i > 0 && strings.HasPrefix(wordNoFlags, "-") == true || strings.HasPrefix(wordNoFlags, "+") == true {
 					flags += " " + wordNoFlags
 					flags += " " + wordNoFlags
+					flagssetbyuser++
+					if strings.HasPrefix(wordNoFlags, "+") == true {
+						numRequiredWords++
+					}
 				}
 				}
 			}
 			}
 		}
 		}
@@ -290,23 +297,16 @@ func handler(w http.ResponseWriter, r *http.Request) {
 					longestWord = word
 					longestWord = word
 					longestwordelementnum = wordcount
 					longestwordelementnum = wordcount
 				}
 				}
-				wordcount++
+				if word != ""{
+					wordcount++
+				}
 			}
 			}
 		}
 		}
 
 
 		//create another query where all compatible words are marked as keywords
 		//create another query where all compatible words are marked as keywords
 		reqwordQuery := ""
 		reqwordQuery := ""
-		flagssetbyuser := 0
-		numRequiredWords := 0
-		wordlen := 0
 		for i, word := range words{
 		for i, word := range words{
 			wordlen = len(word)
 			wordlen = len(word)
-			if (strings.HasPrefix(word, "+") == true || strings.HasPrefix(word, "-") == true) && wordlen > 3{
-				flagssetbyuser++
-				if strings.HasPrefix(word, "+") == true {
-					numRequiredWords++
-				}
-			}
 			if i==0 && (strings.HasPrefix(word, "+") == true || strings.HasPrefix(word, "-") == true) && wordlen > 3{
 			if i==0 && (strings.HasPrefix(word, "+") == true || strings.HasPrefix(word, "-") == true) && wordlen > 3{
 				reqwordQuery += word
 				reqwordQuery += word
 			}
 			}
@@ -328,6 +328,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
 				reqwordQuery += word
 				reqwordQuery += word
 			}
 			}
 		}
 		}
+		reqwordQuery += flags
 
 
 		//fmt.Printf("\n%s",reqwordQuery)
 		//fmt.Printf("\n%s",reqwordQuery)
 
 
@@ -394,7 +395,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
 
 
 		//if no required words set, make the longest word in the query required.
 		//if no required words set, make the longest word in the query required.
 		querywithrequiredword := ""
 		querywithrequiredword := ""
-		if flagssetbyuser == 0 && wordcount > 1 && longestWordLength > 2{
+		if numRequiredWords == 0 && wordcount > 1 && longestWordLength > 2{
 			querywithrequiredword = query + " +"
 			querywithrequiredword = query + " +"
 			querywithrequiredword = querywithrequiredword + longestWord
 			querywithrequiredword = querywithrequiredword + longestWord
 		}		
 		}		
@@ -409,10 +410,13 @@ func handler(w http.ResponseWriter, r *http.Request) {
 			queryWithQuotesAndFlags = queryfix
 			queryWithQuotesAndFlags = queryfix
 			reqwordQuery = queryfix
 			reqwordQuery = queryfix
 		}
 		}
-		if queryOriginal == "c++" || query == "C++" {
-			query = "\"c++\" +programming"
-			queryWithQuotesAndFlags = query
-			reqwordQuery = query
+		if strings.Contains(queryOriginal,"c++")==true || strings.Contains(queryOriginal,"C++")==true{ // :) :( :) :(
+			exactMatch=true
+			queryWithQuotesAndFlags += " +programming"
+			if strings.Contains(queryOriginal," ")==true && longestWordLength>3{
+				queryWithQuotesAndFlags += " +"
+				queryWithQuotesAndFlags += longestWord
+			}
 		}
 		}
 
 
 		querytouse := query
 		querytouse := query
@@ -420,19 +424,16 @@ func handler(w http.ResponseWriter, r *http.Request) {
 			querytouse = querywithrequiredword
 			querytouse = querywithrequiredword
 		}else if numRequiredWords > 0{
 		}else if numRequiredWords > 0{
 			querytouse = reqwordQuery
 			querytouse = reqwordQuery
-		}else{
-			querytouse = query
 		}
 		}
 
 
 		//perform full text search FOR InnoDB STORAGE ENGINE or MyISAM
 		//perform full text search FOR InnoDB STORAGE ENGINE or MyISAM
 		var sqlQuery, id, url, title, description, body string
 		var sqlQuery, id, url, title, description, body string
 	
 	
-		if(exactMatch==false && urlDetected==false && strings.Index(query, " ") != -1 && flagssetbyuser != wordcount){
+		if exactMatch==false && urlDetected==false && strings.Index(query, " ") != -1 && flagssetbyuser + wordcount != flagssetbyuser{
 			sqlQuery = "SELECT id, url, title, description, body FROM windex WHERE MATCH(tags, body, description, title, url) AGAINST('" + querytouse + "' IN BOOLEAN MODE) AND enable = '1' " + additions + "ORDER BY CASE WHEN MATCH(tags) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 30 " + isURL + " WHEN MATCH(title) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 20 WHEN MATCH(body) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) OR MATCH(description) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 15 WHEN MATCH(title) AGAINST('" + reqwordQuery + "' IN BOOLEAN MODE) THEN 14 WHEN MATCH(title) AGAINST('" + querytouse + "' IN BOOLEAN MODE) THEN 13 END DESC, id DESC LIMIT " + lim + " OFFSET " + offset + ""
 			sqlQuery = "SELECT id, url, title, description, body FROM windex WHERE MATCH(tags, body, description, title, url) AGAINST('" + querytouse + "' IN BOOLEAN MODE) AND enable = '1' " + additions + "ORDER BY CASE WHEN MATCH(tags) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 30 " + isURL + " WHEN MATCH(title) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 20 WHEN MATCH(body) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) OR MATCH(description) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 15 WHEN MATCH(title) AGAINST('" + reqwordQuery + "' IN BOOLEAN MODE) THEN 14 WHEN MATCH(title) AGAINST('" + querytouse + "' IN BOOLEAN MODE) THEN 13 END DESC, id DESC LIMIT " + lim + " OFFSET " + offset + ""
 		}else{
 		}else{
 			sqlQuery = "SELECT id, url, title, description, body FROM windex WHERE MATCH(tags, body, description, title, url) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) AND enable = '1' " + additions + "ORDER BY CASE WHEN MATCH(tags) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 30 " + isURL + " WHEN MATCH(title) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 20 END DESC, id DESC LIMIT " + lim + " OFFSET " + offset + ""
 			sqlQuery = "SELECT id, url, title, description, body FROM windex WHERE MATCH(tags, body, description, title, url) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) AND enable = '1' " + additions + "ORDER BY CASE WHEN MATCH(tags) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 30 " + isURL + " WHEN MATCH(title) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 20 END DESC, id DESC LIMIT " + lim + " OFFSET " + offset + ""
 		}
 		}
-		
 		rows, err := db.Query(sqlQuery)
 		rows, err := db.Query(sqlQuery)
 		//fmt.Printf("\n%s\n",sqlQuery)
 		//fmt.Printf("\n%s\n",sqlQuery)
 		if err != nil {
 		if err != nil {
@@ -471,7 +472,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
 			}
 			}
 
 
 			//find query inside body of page
 			//find query inside body of page
-			if exactMatch == false && (flagssetbyuser == 0 || flagssetbyuser == wordcount){
+			if exactMatch == false && (numRequiredWords == 0 || numRequiredWords + wordcount == numRequiredWords){
 				/*					//remove the '*' if contained anywhere in query
 				/*					//remove the '*' if contained anywhere in query
 									if strings.Contains(queryNoQuotes,"*"){
 									if strings.Contains(queryNoQuotes,"*"){
 										queryNoQuotes = strings.Replace(queryNoQuotes, "*", "", -1)
 										queryNoQuotes = strings.Replace(queryNoQuotes, "*", "", -1)
@@ -630,7 +631,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
 				}
 				}
 
 
 				//find query inside body of page
 				//find query inside body of page
-				if exactMatch == false && (flagssetbyuser == 0 || flagssetbyuser == wordcount){
+				if exactMatch == false && (numRequiredWords == 0 || numRequiredWords + wordcount == numRequiredWords){
 					//remove the '*' if contained anywhere in query
 					//remove the '*' if contained anywhere in query
 					//if strings.Contains(queryNoQuotes,"*"){
 					//if strings.Contains(queryNoQuotes,"*"){
 					//	queryNoQuotes = strings.Replace(queryNoQuotes, "*", "", -1)
 					//	queryNoQuotes = strings.Replace(queryNoQuotes, "*", "", -1)

+ 24 - 22
go/core/core.go

@@ -267,6 +267,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
 		queryNoQuotesOrFlags := queryNoQuotes
 		queryNoQuotesOrFlags := queryNoQuotes
 		requiredword := ""
 		requiredword := ""
 		flags := ""
 		flags := ""
+		flagssetbyuser := 0
+		wordlen := 0
+		numRequiredWords := 0
 		//queryNoFlags := ""
 		//queryNoFlags := ""
 		//first remove any flags inside var queryNoQuotes, also grab any required words (+ prefix)
 		//first remove any flags inside var queryNoQuotes, also grab any required words (+ prefix)
 		if strings.Contains(queryNoQuotes, "-") || strings.Contains(queryNoQuotes, "+") {
 		if strings.Contains(queryNoQuotes, "-") || strings.Contains(queryNoQuotes, "+") {
@@ -283,6 +286,10 @@ func handler(w http.ResponseWriter, r *http.Request) {
 				}
 				}
 				if i > 0 && strings.HasPrefix(wordNoFlags, "-") == true || strings.HasPrefix(wordNoFlags, "+") == true {
 				if i > 0 && strings.HasPrefix(wordNoFlags, "-") == true || strings.HasPrefix(wordNoFlags, "+") == true {
 					flags += " " + wordNoFlags
 					flags += " " + wordNoFlags
+					flagssetbyuser++
+					if strings.HasPrefix(wordNoFlags, "+") == true {
+						numRequiredWords++
+					}
 				}
 				}
 			}
 			}
 		}
 		}
@@ -305,7 +312,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
 					}
 					}
 					locateWords=true			
 					locateWords=true			
 				}
 				}
-				wordcount++
+				if word != ""{
+					wordcount++
+				}
 			}
 			}
 			if locateWords == true{
 			if locateWords == true{
 				partialLocate += "THEN 10"
 				partialLocate += "THEN 10"
@@ -315,17 +324,8 @@ func handler(w http.ResponseWriter, r *http.Request) {
 
 
 		//create another query where all compatible words are marked as keywords
 		//create another query where all compatible words are marked as keywords
 		reqwordQuery := ""
 		reqwordQuery := ""
-		flagssetbyuser := 0
-		numRequiredWords := 0
-		wordlen := 0
 		for i, word := range words{
 		for i, word := range words{
 			wordlen = len(word)
 			wordlen = len(word)
-			if (strings.HasPrefix(word, "+") == true || strings.HasPrefix(word, "-") == true) && wordlen > 3{
-				flagssetbyuser++
-				if strings.HasPrefix(word, "+") == true {
-					numRequiredWords++
-				}
-			}
 			if i==0 && (strings.HasPrefix(word, "+") == true || strings.HasPrefix(word, "-") == true) && wordlen > 3{
 			if i==0 && (strings.HasPrefix(word, "+") == true || strings.HasPrefix(word, "-") == true) && wordlen > 3{
 				reqwordQuery += word
 				reqwordQuery += word
 			}
 			}
@@ -347,6 +347,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
 				reqwordQuery += word
 				reqwordQuery += word
 			}
 			}
 		}
 		}
+		reqwordQuery += flags
 
 
 		//fmt.Fprintf(w,"%s\n%s\n", query,offset)
 		//fmt.Fprintf(w,"%s\n%s\n", query,offset)
 		//fmt.Printf("hai\n")
 		//fmt.Printf("hai\n")
@@ -403,7 +404,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
 		if numRequiredWords == 0 && wordcount > 1 && longestWordLength > 2{
 		if numRequiredWords == 0 && wordcount > 1 && longestWordLength > 2{
 			querywithrequiredword = query + " +"
 			querywithrequiredword = query + " +"
 			querywithrequiredword = querywithrequiredword + longestWord
 			querywithrequiredword = querywithrequiredword + longestWord
-		}
+		}	
 
 
 		//perform full text search FOR InnoDB or MyISAM
 		//perform full text search FOR InnoDB or MyISAM
 		var sqlQuery, id, url, title, description, body, idList string
 		var sqlQuery, id, url, title, description, body, idList string
@@ -450,19 +451,20 @@ func handler(w http.ResponseWriter, r *http.Request) {
 			queryWithQuotesAndFlags = queryfix
 			queryWithQuotesAndFlags = queryfix
 			reqwordQuery = queryfix
 			reqwordQuery = queryfix
 		}
 		}
-		if queryOriginal == "c++" || query == "C++" {
-			query = "\"c++\" +programming"
-			queryWithQuotesAndFlags = query
-			reqwordQuery = query
+		if strings.Contains(queryOriginal,"c++")==true || strings.Contains(queryOriginal,"C++")==true{ // :) :( :) :(
+			exactMatch=true
+			queryWithQuotesAndFlags += " +programming"
+			if strings.Contains(queryOriginal," ")==true && longestWordLength>3{
+				queryWithQuotesAndFlags += " +"
+				queryWithQuotesAndFlags += longestWord
+			}
 		}
 		}
 
 
 		querytouse := query
 		querytouse := query
 		if querywithrequiredword != ""{
 		if querywithrequiredword != ""{
 			querytouse = querywithrequiredword
 			querytouse = querywithrequiredword
-		}else if flagssetbyuser > 0{
+		}else if numRequiredWords > 0{
 			querytouse = reqwordQuery
 			querytouse = reqwordQuery
-		}else{
-			querytouse = query
 		}
 		}
 
 
 		if noservers == false {
 		if noservers == false {
@@ -529,7 +531,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
 							sqlQuery = "SELECT id FROM windex WHERE id BETWEEN " + startID + " AND " + endID + " AND enable = '1' " + additions + "ORDER BY CASE WHEN MATCH(tags) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 30 " + isURL + " WHEN MATCH(title) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 20 WHEN MATCH(body) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 19 WHEN MATCH(description) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 15 WHEN MATCH(url) AGAINST('" + query + "' IN BOOLEAN MODE) THEN 0 END DESC, id DESC LIMIT " + repLimStr + " OFFSET " + repOffsetStr + ""
 							sqlQuery = "SELECT id FROM windex WHERE id BETWEEN " + startID + " AND " + endID + " AND enable = '1' " + additions + "ORDER BY CASE WHEN MATCH(tags) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 30 " + isURL + " WHEN MATCH(title) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 20 WHEN MATCH(body) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 19 WHEN MATCH(description) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 15 WHEN MATCH(url) AGAINST('" + query + "' IN BOOLEAN MODE) THEN 0 END DESC, id DESC LIMIT " + repLimStr + " OFFSET " + repOffsetStr + ""
 						}*/
 						}*/
 					}else{
 					}else{
-						if(exactMatch==false && urlDetected==false && oneword==false && flagssetbyuser != wordcount){
+						if(exactMatch==false && urlDetected==false && oneword==false && flagssetbyuser + wordcount != flagssetbyuser){
 							sqlQuery = "SELECT id FROM " + shard + " WHERE MATCH(tags, body, description, title, url) AGAINST('" + querytouse + "' IN BOOLEAN MODE) AND enable = '1' " + additions + "ORDER BY CASE WHEN MATCH(tags) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 30 " + isURL + " WHEN MATCH(title) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 20 WHEN MATCH(body) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) OR MATCH(description) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 15 WHEN MATCH(title) AGAINST('" + reqwordQuery + "' IN BOOLEAN MODE) THEN 14 WHEN MATCH(title) AGAINST('" + querytouse + "' IN BOOLEAN MODE) THEN 13 END DESC, id DESC LIMIT " + repLimStr + " OFFSET " + repOffsetStr + ""
 							sqlQuery = "SELECT id FROM " + shard + " WHERE MATCH(tags, body, description, title, url) AGAINST('" + querytouse + "' IN BOOLEAN MODE) AND enable = '1' " + additions + "ORDER BY CASE WHEN MATCH(tags) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 30 " + isURL + " WHEN MATCH(title) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 20 WHEN MATCH(body) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) OR MATCH(description) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 15 WHEN MATCH(title) AGAINST('" + reqwordQuery + "' IN BOOLEAN MODE) THEN 14 WHEN MATCH(title) AGAINST('" + querytouse + "' IN BOOLEAN MODE) THEN 13 END DESC, id DESC LIMIT " + repLimStr + " OFFSET " + repOffsetStr + ""
 						}else{
 						}else{
 							sqlQuery = "SELECT id FROM " + shard + " WHERE MATCH(tags, body, description, title, url) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) AND enable = '1' " + additions + "ORDER BY CASE WHEN MATCH(tags) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 30 " + isURL + " WHEN MATCH(title) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 20 END DESC, id DESC LIMIT " + repLimStr + " OFFSET " + repOffsetStr + ""
 							sqlQuery = "SELECT id FROM " + shard + " WHERE MATCH(tags, body, description, title, url) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) AND enable = '1' " + additions + "ORDER BY CASE WHEN MATCH(tags) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 30 " + isURL + " WHEN MATCH(title) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 20 END DESC, id DESC LIMIT " + repLimStr + " OFFSET " + repOffsetStr + ""
@@ -581,7 +583,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
 		if numServers == serverCount && numServers > 0 && repsearchfail == 0 {
 		if numServers == serverCount && numServers > 0 && repsearchfail == 0 {
 			sqlQuery = "SELECT id, url, title, description, body FROM windex WHERE id IN (" + idList + ") AND enable = '1' " + additions + "ORDER BY CASE WHEN LOCATE('" + queryNoQuotesOrFlags + "', tags) THEN 30 " + isURLlocate + " WHEN LOCATE('" + queryNoQuotesOrFlags + "', title) THEN 20 WHEN LOCATE('" + queryNoQuotesOrFlags + "', body) OR LOCATE('" + queryNoQuotesOrFlags + "', description) THEN 15" + partialLocate + " END DESC, id DESC LIMIT " + lim + " OFFSET " + strconv.Itoa(rangeOffset) + ""
 			sqlQuery = "SELECT id, url, title, description, body FROM windex WHERE id IN (" + idList + ") AND enable = '1' " + additions + "ORDER BY CASE WHEN LOCATE('" + queryNoQuotesOrFlags + "', tags) THEN 30 " + isURLlocate + " WHEN LOCATE('" + queryNoQuotesOrFlags + "', title) THEN 20 WHEN LOCATE('" + queryNoQuotesOrFlags + "', body) OR LOCATE('" + queryNoQuotesOrFlags + "', description) THEN 15" + partialLocate + " END DESC, id DESC LIMIT " + lim + " OFFSET " + strconv.Itoa(rangeOffset) + ""
 		} else { //else, if no replication servers or there was some sort of error, just search the database locally instead
 		} else { //else, if no replication servers or there was some sort of error, just search the database locally instead
-			if(exactMatch==false && urlDetected==false && oneword==false && flagssetbyuser != wordcount){
+			if(exactMatch==false && urlDetected==false && oneword==false && flagssetbyuser + wordcount != flagssetbyuser){
 				sqlQuery = "SELECT id, url, title, description, body FROM windex WHERE MATCH(tags, body, description, title, url) AGAINST('" + querytouse + "' IN BOOLEAN MODE) AND enable = '1' " + additions + "ORDER BY CASE WHEN MATCH(tags) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 30 " + isURL + " WHEN MATCH(title) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 20 WHEN MATCH(body) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) OR MATCH(description) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 15 WHEN MATCH(title) AGAINST('" + reqwordQuery + "' IN BOOLEAN MODE) THEN 14 WHEN MATCH(title) AGAINST('" + querytouse + "' IN BOOLEAN MODE) THEN 13 END DESC, id DESC LIMIT " + lim + " OFFSET " + offset + ""
 				sqlQuery = "SELECT id, url, title, description, body FROM windex WHERE MATCH(tags, body, description, title, url) AGAINST('" + querytouse + "' IN BOOLEAN MODE) AND enable = '1' " + additions + "ORDER BY CASE WHEN MATCH(tags) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 30 " + isURL + " WHEN MATCH(title) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 20 WHEN MATCH(body) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) OR MATCH(description) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 15 WHEN MATCH(title) AGAINST('" + reqwordQuery + "' IN BOOLEAN MODE) THEN 14 WHEN MATCH(title) AGAINST('" + querytouse + "' IN BOOLEAN MODE) THEN 13 END DESC, id DESC LIMIT " + lim + " OFFSET " + offset + ""
 			}else{
 			}else{
 				if(shards==false){//depricated
 				if(shards==false){//depricated
@@ -635,7 +637,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
 				ids = append(ids,id)
 				ids = append(ids,id)
 
 
 				//find query inside body of page
 				//find query inside body of page
-				if exactMatch == false && (flagssetbyuser == 0 || flagssetbyuser == wordcount){
+				if exactMatch == false && (flagssetbyuser == 0 || flagssetbyuser + wordcount == flagssetbyuser){
 					//remove the '*' if contained anywhere in query
 					//remove the '*' if contained anywhere in query
 					/*if strings.Contains(queryNoQuotes,"*"){
 					/*if strings.Contains(queryNoQuotes,"*"){
 						queryNoQuotes = strings.Replace(queryNoQuotes, "*", "", -1)
 						queryNoQuotes = strings.Replace(queryNoQuotes, "*", "", -1)
@@ -853,7 +855,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
 				}
 				}
 
 
 				//find query inside body of page
 				//find query inside body of page
-				if exactMatch == false && (flagssetbyuser == 0 || flagssetbyuser == wordcount){
+				if exactMatch == false && (flagssetbyuser == 0 || flagssetbyuser + wordcount == flagssetbyuser){
 
 
 					if len(requiredword) > 0 { //search for position of required word if any, else search for position of whole query
 					if len(requiredword) > 0 { //search for position of required word if any, else search for position of whole query
 						pos = strings.Index(strings.ToLower(body), strings.ToLower(requiredword))
 						pos = strings.Index(strings.ToLower(body), strings.ToLower(requiredword))