SQL Server FTS: ranking a bit weird

I am using SQL Server 2008 full-text search engine on my website. I have a search SP that shows results sorted by ranking.

I split the search string and pass it to the FTS query engine, for example, (the search string is “test search”:

("*test*" ~ "*search*") OR ("*test*" OR "*search*"). 

If the result string has a “test search” of the string and the other has “check something else”. The latter is rated higher.

I don’t understand how this can be - obviously, the phrase “test search” is closer. I believe this has something to do with how I pass the test string to the FTS. Any ideas? Suggestions?

+4
source share
1 answer

All OR'ed search terms have the same weight. To increase the rank of the phrase "NEAR search test", you must specify a greater weight.

Example

 SELECT Srch.* FROM CONTAINSTABLE ( MyTable, SearchColumn, -- must specify a weight if one phrase is more important 'ISABOUT(test ~ search weight(.7), test weight(.1), search weight(.2))', LANGUAGE 1033, -- english 100 -- TOP N RANK ) Srch 
+2
source

Source: https://habr.com/ru/post/1302517/


All Articles