本文介绍了MySQL匹配全文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图用mysql做一个全文搜索,来匹配一个字符串。例如,字符串'passat 2.0 tdi':

  AND MATCH(
records_veiculos.titulo,records_veiculos.descricao

反应(
'passat 2.0 tdi'WITH QUERY EXPANSION

正在返回第一个结果(其他都很好): p>

 大众帕萨特Variant 1.9 TDI- ANO 2003 

这是不正确的,因为在这个例子中没有2.0。



它可能是什么?

编辑:另外,由于这可能是一个大型数据库(预计最多500.000条记录),这种搜索方法最适合本身,还是安装像Sphinx这样的其他搜索引擎会更好?或者,如果没有,如何显示相关结果?



edit2 :为记录,尽管问题被标记为已回答, MySQL分隔符的问题仍然存在,所以如果任何人有关于如何避免分隔符的建议,将不胜感激,值得关注500点。我发现增加结果集的溶剂是用IN BOOLEAN MODE替换WITH QUERY EXPANSION,使用操作符强制引擎获得我需要的词,如:

<$ p $ (
'+ passat +2.0 + tdi'BOOLEAN MODE $ b(
records_veiculos.titulo,records_veiculos.descricao





$ p
$ b

完全没有解决,但至少结果的相关性已经改变显着的。

解决方案

默认情况下,我相信mysql只索引和匹配4个或更多字符的单词。你也可以尝试逃避这段时间?它可能会被忽略,或者将其用作停止字符。


Im' trying to do a fulltext search with mysql, to match a string. The problem is that it's returning odd results in the first place.

For example, the string 'passat 2.0 tdi' :

            AND MATCH (
            records_veiculos.titulo, records_veiculos.descricao
            )
            AGAINST (
             'passat 2.0 tdi' WITH QUERY EXPANSION
            )

is returning this as the first result (the others are fine) :

Volkswagen Passat Variant 1.9 TDI- ANO 2003

wich is incorrect, since there's no "2.0" in this example.

What could it be?

edit: Also, since this will probably be a large database (expecting up to 500.000 records), will this search method be the best for itself, or would it be better to install any other search engine like Sphinx? Or in case it doesn't, how to show relevant results?

edit2: For the record, despite the question being marked as answered, the problem with the MySQL delimiters persists, so if anyone has a suggestion on how to escape delimiters, it would be appreciated and worth the 500 points at stake. The sollution I found to increase the resultset was to replace WITH QUERY EXPANSION with IN BOOLEAN MODE, using operators to force the engine to get the words I needed, like :

AND MATCH (
records_veiculos.titulo, records_veiculos.descricao
)
AGAINST (
 '+passat +2.0 +tdi' IN BOOLEAN MODE
)

It didn't solve at all, but at least the relevance of the results as changed significantly.

解决方案

By default I believe mysql only indexes and matches words with 4 or more characters. You could also try escaping the period? It might be ignored this or otherwise using it as a stop character.

这篇关于MySQL匹配全文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 05:40