Let's say I have a table with Autho开发者_运维知识库r info. The author's name is stored in the format "LastName, FirstName" (ex: King, Stephen). This table is queried by a site which uses Full Text Search in Sql Server 2008. The end user will almost always enter "Stephen King" which brings back no results. However, if the user types "King Stephen", results will come back. An example query that works looks like this:
DECLARE @SearchWord nvarchar(30)
SET @SearchWord = N'"' + 'king stephen' + '"'
SELECT Author
FROM Items
WHERE CONTAINS(Author, @SearchWord)
Any ideas why I can't get the common search term ("Stephen King") to work while the uncommon way ("King Stephen") works? It could be due to the quotes around the search term, but I'm not sure how to work around this. Any ideas? Thanks.
placing the quotes around the the search item will make it a single word for full text indexs, you have to break it into multiple single word like "king ","stephen" to get result
精彩评论