我有一张桌子,上面有短语:
buy car
adopt cute cat
make big money
buy helicopter
big nasty dog
带有FULLTEXT索引。我想找到所有短语,它们完全出现在给定的文本中。
对于文字:
I want to buy car and then buy and adopt cute cat tomorrow.
我应该得到:
buy car
adopt cute cat
我尝试查询:
SELECT * FROM `phrases` WHERE MATCH(`phrase`) AGAINST('I want to buy car and then buy and adopt cute cat tomorrow.' IN BOOLEAN MODE)=`numWords`
但这给了我
buy helicopter //since there are twice "buy" and the number of total words is 2
adopt cute cat
提前致谢。
最佳答案
只需在查询中添加AND phrases LIKE '%I want to buy car and then buy and adopt cute cat tomorrow.%'
。它将使用FULLTEXT键快速找到匹配项,然后对结果进行后过滤以确保短语列中的短语完全相同。
关于mysql - 仅查找具有FULLTEXT索引的完全匹配项,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33634654/