gpt4 book ai didi

mysql - 仅查找与 FULLTEXT 索引完全匹配的内容

转载 作者:行者123 更新时间:2023-11-29 21:51:02 26 4
gpt4 key购买 nike

我有一个包含短语的表格:

buy car
adopt cute cat
make big money
buy helicopter
big nasty dog

上面有全文索引。我想找到给定文本中完全出现的所有短语。

对于文本:

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 短语,例如“%I Want to buy car and then buy and领养可爱的猫明天。%”。它将使用 FULLTEXT 键快速查找匹配项,然后对结果进行后过滤以确保短语列中存在准确的短语。

关于mysql - 仅查找与 FULLTEXT 索引完全匹配的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33634654/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com