gpt4 book ai didi

php - MySQL 全词搜索

转载 作者:行者123 更新时间:2023-11-29 03:45:33 25 4
gpt4 key购买 nike

我有一个关于 MySQL ALL-Word 搜索能力的简单问题:

是否可以在 MySQL 中执行全词搜索并使词的顺序重要? (显然,默认情况下单词的顺序无关紧要)

例如,假设我有这个查询:

SELECT firstname, lastname FROM Person
WHERE MATCH (firstname, lastname)
AGAINST ("+firstname +lastname" IN BOOLEAN MODE);

我希望在结果中名字总是出现在姓氏之前

我怎样才能做到这一点?

在此先感谢您的帮助

最佳答案

我不明白你的意思

I want the firstname to ALWAYS appear before the lastname in the results

这没有意义,因为根据您的查询,返回的所有记录都将匹配名字和姓氏。

总之,没有评分词积分系统。但也许您可以尝试波浪号运算符来降低相关性

~

A leading tilde acts as a negation operator, causing the word's contribution to the row's relevance to be negative. This is useful for marking “noise” words. A row containing such a word is rated lower than others, but is not excluded altogether, as it would be with the - operator.

关于php - MySQL 全词搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6131881/

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