ElasticSearch-带有模糊搜索的cross_fields多重匹配 [英] ElasticSearch - cross_fields multi match with fuzzy search

查看:72
本文介绍了ElasticSearch-带有模糊搜索的cross_fields多重匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有代表用户的文件.它们具有字段 name surname .

I have documents that represent users. They have fields name and surname.

比方说,我有两个用户编入索引-迈克尔·杰克逊(Michael Jackson)和迈克尔·斯塔尔(Michael Starr).我希望这些示例搜索有效:

Let's say I have two users indexed - Michael Jackson and Michael Starr. I want these sample searches to work:

  1. Michael => { Michael Jackson Michael Starr }
  2. Jack Mich => { Michael Jackson }(不完整的单词和相反的顺序)
  3. Michal Star => { Michael Starr }(模糊搜索)
  1. Michael => { Michael Jackson, Michael Starr }
  2. Jack Mich => { Michael Jackson } (incomplete words and reversed order)
  3. Michal Star => { Michael Starr } (fuzzy search)

我尝试了不同的查询,并从具有cross_fields类型的multi_match查询中获得了最佳结果.但是有两个问题:

I tried different queries and got the best results from multi_match query with cross_fields type. There are 2 problems though:

  1. 仅当两个单词中的至少一个完成时才找到内容.如果键入 Jackson Mich ,它将找到 Michael Jackson ;但是,如果键入 Jack Mich ,它将不会找到任何内容(但我希望找到它.)
  2. 不能将其设置为模糊搜索.我确实需要模糊搜索,但是保持cross_fields类型的multi_match质量.
  1. It only finds something when at least one of the two words is complete. If I type Jackson Mich, it finds Michael Jackson but if I type Jack Mich, it doens't find anything (but I want it to find it).
  2. It cannot be set to fuzzy search. I really need the fuzzy search but keep the quality of multi_match with cross_fields type.

换句话说,我想实现类似于Facebook的人搜索.

我是ElasticSearch的新手,所以也许我缺少明显的东西.对不起,我愿意.

I'm pretty new to ElasticSearch so maybe I'm missing something obvious. Sorry if I do.

推荐答案

Jack Mich搜索类型

Jack Mich type of searches

  • 请确保在查询时使用或"而不是与",例如杰克·米奇
  • 本质上,您还想对字段进行部分匹配.为此,您需要在这些字段上启用nGrams(在映射中执行此操作),以便索引具有部分单词的匹配项

您使用的是正确的查询类型.这两个应该可以解决您的问题.

You are using the correct query type. These two should solve your problems.

PS:我们所有人都在这里学习,一起做是一件很有趣的事情:)

PS: We all are learning here, doing that together is fun :)

这篇关于ElasticSearch-带有模糊搜索的cross_fields多重匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆