简体   繁体   English

与 MySql LIKE 相比,Sphinx 搜索返回的结果较少

[英]Sphinx Search returns less result as compared to MySql LIKE

When I try simple MySql Query当我尝试简单的 MySql 查询时

select id 
from `contacts` 
where name LIKE '%abdul%'
OR email LIKE '%abdul%'
OR phone LIKE '%abdul%'

it returns 278 records from my database where as when I search through Sphinx search like this它从我的数据库中返回 278 条记录,当我像这样通过 Sphinx 搜索时

$sphinx = new SphinxClient();
$sphinx->setServer('localhost',9312);
$sphinx->setLimits(0,1000);
$sphinx->setMatchMode(SPH_MATCH_EXTENDED2);
$result = $sphinx->query('abdul','test1');

It returns only 112 records.它只返回 112 条记录。 Is there any way to get same record as MySql Query in Sphinx?有没有办法在 Sphinx 中获得与 MySql 查询相同的记录?

Sphinx doesn't do wildcard search by default. Sphinx 默认不进行通配符搜索。 Make sure to add确保添加

min_infix_len=2

to your index config, rebuild it and then try到您的索引配置,重建它然后尝试

$result = $sphinx->query('*abdul*','test1');

If it doesn't help you need to inspect thoroughly the documents that differ to understand the root cause, since there may be other reasons due to the fact that LIKE in MySQL just does basic wildcard search while Sphinx first tokenizes your text, builds in inverted index and the uses it for search.如果它没有帮助,您需要彻底检查不同的文档以了解根本原因,因为可能还有其他原因,因为 MySQL 中的 LIKE 只是进行基本的通配符搜索,而 Sphinx 首先标记您的文本,倒置构建索引并将其用于搜索。 Much more complex process than just LIKE.比 LIKE 复杂得多的过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM