我正在使用 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
与这些较小的词一起使用,还是应该完全排除它们?如果这些较小的词在搜索中确实有意义,那么如何将它们包含在搜索中? 最佳答案
这些不是“小词”,它们是停用词表上的常用词。它们被忽略。
请参阅 BOL 上的 Stopwords and Stoplists。
关于sql - CONTAINSTABLE 查询无法识别小词,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3821749/