SQL Server CONTAINS 包含数字没有给出结果
我有一个全文索引的数据库表,我使用 CONTAINS 函数对其执行搜索查询。
当我这样做时:
SELECT * FROM Plants WHERE CONTAINS(Plants.Description, '"Plant*" AND "one*"');
我会得到与带有“植物”和“一个”一词的描述相匹配的所有正确结果。
有些植物被命名为“植物 1”、“植物 2”等,这就是问题所在。
当我这样做时,我没有得到任何结果:
SELECT * FROM Plants WHERE CONTAINS(Plants.Description, '"Plant*" AND "1*"');
有人知道为什么吗?
I have a database table which is full-text indexed and i use the CONTAINS-function to perform a search-query on it.
When I do:
SELECT * FROM Plants WHERE CONTAINS(Plants.Description, '"Plant*" AND "one*"');
I get back all correct results matching a description with the words "Plant" and "one".
Some plant are named like "Plant 1", "Plant 2" etc. and this is the problem.
When i do this, i get no results:
SELECT * FROM Plants WHERE CONTAINS(Plants.Description, '"Plant*" AND "1*"');
Anyone know why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有一个未在关键字搜索中索引的常用单词列表,例如“and”和“the”。
我相信文本“1”也出现在该列表中。因此它不会出现在索引中,并且无法使用 CONTAINS 子句找到。
如果我没记错的话,有一个管理界面可以让您编辑常用单词列表。几年前,我尝试过编辑一次,但我记得编辑后很难分辨出其中的差异。
There is a list of commonly-used words that are not indexed in a keyword search, such as "and" and "the".
I believe the text "1" also appears in that list. Therefore it doesn't appear in the index, and can't be found with the CONTAINS clause.
If I recall correctly, there is an admin interface to allow you to edit that list of common words. I tried editing it once, a few years ago, and I recall having trouble telling the difference after I did.
达安是对的。 1. 将通配符放置在搜索项的两侧,您需要在整个字符串中搜索该搜索项,无论其位置如何。
Daan is correct. you need another
*
before the 1. Placing wildcards either side of a search term searches the entire string for the search term regardless of its position.