Elasticsearch单词自动完成,带有文档计数 [英] Elasticsearch word autocomplete with document counts

查看:131
本文介绍了Elasticsearch单词自动完成,带有文档计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够将部分单词自动完成为在文档中找到的完整单词,并返回单词列表和找到这些单词的文档数量.

I'd like to be able to autocomplete partial words to full words found in my documents and return a list of words and the number of documents those words are found in.

如果我也可以对现有查询结果执行此操作,那将是很好的.因此,如果用户输入"red tr",我将得到所有与红色匹配的文档的结果,然后是带有计数的卡车或火车等单词.

It would be great if I could also do this on an existing query results. So if they user typed "red tr" I would have results for all documents that match red and then words like truck or train with their counts.

推荐答案

您是对的.建议者不会同时完成并给您提供文档频率.

You're right. Suggesters won't complete and give you document-frequency in the same go.

一种解决方案:

性能不会像zippy一样,但是如果您执行以下操作(不使用建议程序),可能仍然可以接受:

Performance won't be as zippy, but probably still acceptable if you do the following (not using Suggesters):

  • 运行使用size: 0match_all查询" rel ="nofollow">前缀过滤器以及用户键入的前缀.
  • 在同一查询中,请求带小格字段中.
  • 将聚合结果用作完成建议.
  • Run a size: 0 match_all query filtered using a Prefix Filter with your user's typed prefix.
  • In the same query, request a Terms Aggregation over a shingled field in your index.
  • Use the aggregation results as your completion suggestions.

注意:

  • 请参阅有关
  • See the section about filtering term agg values for noise suppression. (You'll need this since the default agg result ordering is by descending document count.)
  • Also, note that document counts are approximate wrt shard_size requested.

这篇关于Elasticsearch单词自动完成,带有文档计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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