我在SQL Server数据库中有一个Products表,我不得不对使用全文索引的旧存储过程进行故障排除.出于我们的目的,我们假设Products表有两个字段ID,Keywords.并且关键字字段填充以下内容:
ROLAND SA-300这款Roland SA-300处于MINT状态!
当我运行以下语句时,我能够检索记录:
SELECT * FROM Products WHERE Keywords LIKE '%SA-300%'
但是,当我运行以下任何语句时,我得到零结果:
SELECT * FROM Products WHERE CONTAINS(Keywords, ' SA-300 ') SELECT * FROM Products WHERE CONTAINS(Keywords, 'SA-300') SELECT * FROM Products WHERE CONTAINS(Keywords, '"SA-300"') SELECT * FROM Products WHERE CONTAINS(Keywords, '"*SA-300*"')
但我知道CONTAINS()函数正在运行,因为当我运行其中任何一个时,我得到了结果:
SELECT * FROM Products WHERE CONTAINS(Keywords, ' Roland ') SELECT * FROM Products WHERE CONTAINS(Keywords, 'Roland') SELECT * FROM Products WHERE CONTAINS(Keywords, '"Roland"') SELECT * FROM Products WHERE CONTAINS(Keywords, '"*Roland*"') SELECT * FROM Products WHERE CONTAINS(Keywords, 'Roland')
我需要弄清楚为什么CONTAINS()函数不能用于'SA-300'术语.我是全文索引的新手,所以任何帮助都表示赞赏.
两个想法:
(1)连字符可能被视为一个字断裂这些返回什么?
SELECT * FROM Products WHERE CONTAINS(Keywords, 'SA') SELECT * FROM Products WHERE CONTAINS(Keywords, 'SA 300') SELECT * FROM Products WHERE CONTAINS(Keywords, 'SA300')
看到这个其他问题.
(2)您是否尝试过重建全文索引?它可能已经过时了.