全文搜索 - 搜索词排序
假设我有一张包含作者信息的表格。作者姓名以“姓氏、名字”的格式存储(例如:King、Stephen)。该表由使用 Sql Server 2008 中的全文搜索的站点查询。最终用户几乎总是输入“Stephen King”,这不会返回任何结果。但是,如果用户输入“King Stephen”,结果就会返回。一个有效的示例查询如下所示:
DECLARE @SearchWord nvarchar(30)
SET @SearchWord = N'"' + 'king stephen' + '"'
SELECT Author
FROM Items
WHERE CONTAINS(Author, @SearchWord)
有什么想法为什么我无法让常见搜索词(“Stephen King”)起作用,而不常见的方式(“King Stephen”)却起作用?这可能是由于搜索词周围的引号造成的,但我不确定如何解决这个问题。有什么想法吗?谢谢。
Let's say I have a table with Author 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将引号放在搜索项周围将使其成为全文索引的单个单词,
你必须将它分成多个单个单词,例如“king”,“stephen”才能得到结果
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