我在sql Server数据库中有一个Products表,我不得不对使用全文索引的旧存储过程进行故障排除.为了我们的目的,假设“产品”表有两个字段ID,关键字.关键字字段填充以下内容:
ROLAND SA-300 This Roland SA-300 is
in MINT condition!
当我运行以下语句时,我可以检索记录:
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)您是否尝试重建全文索引?有可能是过时的.