【问题标题】:'best match' human name search/rank using Sphinx search使用 Sphinx 搜索的“最佳匹配”人名搜索/排名
【发布时间】:2013-09-19 06:00:07
【问题描述】:

我正在尝试将预测性“最佳匹配”名称搜索功能添加到我构建的自定义 CRM 中,但遇到了一些问题。我决定选择Sphinx,认为它可以满足我开箱即用的需求,但我遇到了一些问题。我了解 sphinx 使用的匹配模式,但我不确定如何获得这样的东西,例如:

如果我查询:Mike Shinoda

它应该能够拉出这样的匹配,按最佳匹配排名:Mike Shinoda | Shinoda, Mike | Mike Shinoji | Michael Shinoda | Shinoda, Michael | Mike James Shinoda | Mike and Ike Shinoda | Shinoda, Miles

做这样的事情最好的方法是什么?我没有和 Sphinx 结婚,我只是找不到任何看起来可以做得更好的东西

我确实已经尝试在这个堆栈问题Sphinx and "did you mean ... ?" suggestions idea. WIll it work? 中实施建议,但它并没有真正发挥作用,因为匹配模式SPH_MATCH_ANY 匹配的记录太多,而SPH_MATCH_ALL 会提取像@987654327 这样的记录@当查询为'sheryl curry'时(因为sheryl curry中的所有字母都在'andrus Cheryl'

编辑

我只索引一个字段:contact_name

【问题讨论】:

  • 你能说出你正在索引的所有字段吗?

标签: php mysql sphinx


【解决方案1】:

首先狮身人面像不会知道迈克 = 迈克尔。您必须明确告诉它这样的“等价物”——wordforms 功能特别适用于它:)

> 因为 sheryl curry 中的所有字母都在 'andrus Cheryl' 中

Sphinx 不会那样做。 Sphinx 匹配整个单词。它不进行“重新排列的字母”匹配。

除非您专门实施了该功能(也许您已经从您的意思是建议中获得) - 在这种情况下,它并不是您真正想要的。

建议回到普通的狮身人面像索引(没有三元组),然后运行类似的查询

"^Mike Shinoda$" | "Mike Shinoda" | "^Mike Shinoda" | "Mike Shinoda$" | (^Mike Shinoda) | (Mike Shinoda$) | (Mike Shinoda) | (Mike Shinoda)

使用SPH_MATCH_EXTENDEDSPH_RANKING_WORDCOUNT

wordforms 一起照顾 Michael > Mike 等价物。

【讨论】:

  • 感谢您的回复,不过我想知道,看起来wordforms 指令要求您在文本文件中明确定义关系,例如mike > michael,但有成千上万名字,我不可能知道他们所有预期的词形.. 我想我希望它匹配第一个 Mi 部分,然后因为 Shinoda 匹配,它应该比其他匹配更高 Michael Shinoda MiMichael 比赛中.. 我正在和min_infix_lenexpand_keywords 一起玩,结果稍微好一点.. 还有更多提示吗?
  • expand_keywords 在这种情况下不会直接帮助您,因为您需要模糊匹配,而不仅仅是推广整个单词。您可以启用min_prefix_len 并设置enable_star=1。然后添加说` | (Mi* Shinoda)` 作为上述查询的术语,因此包含前缀匹配项。但仍然会得到你可能不想要的“Michele Shinoda”。
猜你喜欢
  • 2014-03-28
  • 1970-01-01
  • 2017-08-07
  • 2020-08-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-25
相关资源
最近更新 更多