Over the past two hours, I have been busy with all sorts of SQL Server full-text searches. However, I still can’t understand how the rating works. I came across several examples that really confuse me as to how they are taller than others. for example
I have a table with 5 columns + more that are not indexed. All fields are nvarchar .
I run this query (well, almost .. I reprinted with different names)
SET @SearchString = REPLACE(@Name, ' ', '*" OR "') --Splits words with an OR between SET @SearchString = '"' +@SearchString +'*"' print @SearchString; SELECT ms.ID, ms.Lastname, ms.DateOfBirth, ms.Aka, ms.Key_TBL.RANK, ms.MiddleName, ms.Firstname FROM View_MemberSearch as ms INNER JOIN CONTAINSTABLE(View_MemberSearch, (ms.LastName, ms.Firstname, ms.MiddleName, ms.Aka, ms.DateOfBirth), @SearchString) AS KEY_TBL ON ms.ID = KEY_TBL.[KEY] WHERE KEY_TBL.RANK > 0 ORDER BY KEY_TBL.RANK DESC;
Thus, if I search for 11/05/1964 JOHN JACKSON , I would get "11/05/1964" OR "JOHN *" OR "JACKSON *" and these results:
ID -- First Name -- Middle Name -- Last Name -- AKA -- Date of Birth -- SQL Server RANK ---------------------------------------------------------------------------------- 1 | DAVE | JOHN | MATHIS | NULL | 11/23/1965 | 192 2 | MARK | JACKSON | GREEN | NULL | 05/29/1998 | 192 3 | JOHN | NULL | JACKSON | NULL | 11/05/1964 | 176 4 | JOE | NULL | JACKSON | NULL | 10/04/1994 | 176
So finally my question. I don’t see how lines 1 and 2 are higher than line 3, and why line 3 is evaluated the same as line 4. Line 2 should have the highest rank, seeing that the search line also matches the first and last name as the date of birth.
If I change OR to AND, I will not get any results.
sql-server sql-server-2005 full-text-search
corymathews
source share