本文介绍了MySQL全文索引给出完全匹配和部分匹配的相同分数,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在带有全文索引的mysql 5.6中有这种奇怪的行为

I am having this weird behavior in mysql 5.6 with full text indexes

我正在尝试搜索患者数据库,然后首先获得精确匹配,然后按最低分按分数进行分,因此我不会返回100000+结果,只是一些建议,以防止重复输入EHR类型的应用程序

I am trying to search a patients database and get the exact matches first then partials by score with a Min Score so i don't return 100000+ results just some suggestions to prevent duplicates into a EHR type of app

问题是完全匹配和部分匹配具有相同的分数...

The problem is that the exact and partial matches have the same score...

这是预期的行为吗?我有什么选择?

Is that an expected behavior?what options do I have?

推荐答案

您说的是完全匹配和部分匹配的分数相同,但是示例中没有任何完全匹配的分数.(路易斯测试"!=路易斯文本").它只是具有各种局部匹配.

You stated that you had the same score for exact matches and partials, but your example doesn't have any exact matches in it. ("Luis Test" != "Luis Text"). It just has various partial matches.

这是预期的行为,因为使用自然语言模式"进行的匹配仅面向单词.它不会对部分单词匹配进行评分-也就是说,相似的单词不会计入相关性值.由于每个记录中匹配的单词数相同,并且每个记录具有相同的单词总数,因此它们每个都具有相同的相关性值(得分).

It's expected behavior because MATCH using NATURAL LANGUAGE MODE is word-oriented only. It doesn't score partial word matches--i.e, similar words don't count towards the relevance value. Since the same number of words are matched in each record and each record has the same total number of words, they each get the same relevance value (score).

如果您想对单词进行模糊匹配,则应查看此SO问题以获取可能的替代匹配方案:

If you want fuzzy matching on words, you should look at this SO question for possible alternative matching schemes:How do I do a fuzzy match of company names in MYSQL with PHP for auto-complete?

这篇关于MySQL全文索引给出完全匹配和部分匹配的相同分数,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 05:42