CONTAINSTABLE 查询无法识别小单词
我正在使用 CONTAINSTABLE
搜索两个表列。一旦搜索包含诸如“the”“for”“a”之类的小词,即使它们实际存在于列中,搜索也不会返回任何结果。
简单的例子。正在搜索的列包含文本。 “系统需要升级”
以下 SQL 返回 0 行
SELECT * FROM Incident WHERE (TicketNumber IN (
SELECT TicketNumber FROM [Action] FT_TBL INNER JOIN
CONTAINSTABLE(Action, Text, '"system" AND "needs" AND "to" AND "upgraded" AND NOT "Search Summary"') KEY_TBL ON FT_TBL.ID = KEY_TBL.[KEY]
UNION
SELECT TicketNumber FROM [Incident] FT_TBL INNER JOIN
CONTAINSTABLE(Incident, Subject, '"system" AND "needs" AND "to" AND "upgraded"') AS KEY_TBL ON FT_TBL.TicketNumber = KEY_TBL.[KEY]))
一旦省略“to”,它就可以正常工作:
SELECT * FROM Incident WHERE (TicketNumber IN (
SELECT TicketNumber FROM [Action] FT_TBL INNER JOIN
CONTAINSTABLE(Action, Text, '"system" AND "needs" AND "upgraded" AND NOT "Search Summary"') KEY_TBL ON FT_TBL.ID = KEY_TBL.[KEY]
UNION
SELECT TicketNumber FROM [Incident] FT_TBL INNER JOIN
CONTAINSTABLE(Incident, Subject, '"system" AND "needs" AND "upgraded"') AS KEY_TBL ON FT_TBL.TicketNumber = KEY_TBL.[KEY]))
如何将 CONTAINSTABLE
与这些较小的单词一起使用,还是应该将它们完全省略?如果这些较小的词在搜索中确实有意义,那么如何将它们包含在搜索中?
I'm using CONTAINSTABLE
to search two table columns. Once the search contains small words like 'the' 'for' 'a' the search returns no results even when they are actually present in the column.
Quick example. Column being searched contains the text. 'System needs to be upgraded'
Following SQL returns 0 rows
SELECT * FROM Incident WHERE (TicketNumber IN (
SELECT TicketNumber FROM [Action] FT_TBL INNER JOIN
CONTAINSTABLE(Action, Text, '"system" AND "needs" AND "to" AND "upgraded" AND NOT "Search Summary"') KEY_TBL ON FT_TBL.ID = KEY_TBL.[KEY]
UNION
SELECT TicketNumber FROM [Incident] FT_TBL INNER JOIN
CONTAINSTABLE(Incident, Subject, '"system" AND "needs" AND "to" AND "upgraded"') AS KEY_TBL ON FT_TBL.TicketNumber = KEY_TBL.[KEY]))
Once 'to' is omitted it works fine:
SELECT * FROM Incident WHERE (TicketNumber IN (
SELECT TicketNumber FROM [Action] FT_TBL INNER JOIN
CONTAINSTABLE(Action, Text, '"system" AND "needs" AND "upgraded" AND NOT "Search Summary"') KEY_TBL ON FT_TBL.ID = KEY_TBL.[KEY]
UNION
SELECT TicketNumber FROM [Incident] FT_TBL INNER JOIN
CONTAINSTABLE(Incident, Subject, '"system" AND "needs" AND "upgraded"') AS KEY_TBL ON FT_TBL.TicketNumber = KEY_TBL.[KEY]))
How can CONTAINSTABLE
be used with these smaller words, or should they be left out altogether? If those smaller words are actually meaningful in the search, how can they be included in the search?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这些不是“小词”,这些是停止列表上的常见词。他们被忽视了。
请参阅 BOL 上的停用词和停用词列表。
These are not "small words", these are common words that are on the stop list. They are ignored.
See Stopwords and Stoplists on BOL.
请参阅关于创建和参与自定义的答案的结尾从空列表开始的全文非索引字表。我检查了一下,如果你的查询为空,则可以使用“to”、“be”、“the”、“for”等。
更新:
SQL Server 2005 应该有 MSSQL\FTData\noiseENG.txt。
我建议查看问题“Sql 中的干扰词”的答案Server 2005 全文搜索”
Please see the end of my answer on creating and engaging custom Full-text Stoplist starting from empty one. I checked and with empty one your query works with "to", "be", "the", "for", etc.
Update:
SQL Server 2005 should have MSSQL\FTData\noiseENG.txt.
I'd reccommend to view answers to question "Noise Words in Sql Server 2005 Full Text Search"