简体   繁体   English

elasticsearch返回所有找到的聚合

[英]elasticsearch returning all found aggregations

I'm using the example application from github.com/searchly/searchly-php-sample with Searchly service. 我正在将github.com/searchly/searchly-php-sample中的示例应用程序与Searchly服务一起使用。

I've came a simple where I want the search results to return all the aggregations(continued as 'aggs') from the search results, not only the ones I specified. 我来了一个简单的地方,我希望搜索结果返回搜索结果中的所有聚合(续为“ ags”),而不仅仅是我指定的聚合。

Currently the code for the aggs is: 当前aggs的代码为:

$searchParams['body']['aggs']['resolution']['terms']['field'] = 'resolution';

this returns the resolution agg but I can not find the way for it to return all of the possible aggs from the search results. 这将返回分辨率agg,但是我找不到从搜索结果中返回所有可能aggs的方法。

Is it possible or does it require me to save the aggs some where and then just list them when I do the actual search request? 是否可以,或者是否需要我将aggs保存在某个位置,然后在执行实际搜索请求时仅列出它们?

Thank you! 谢谢!

As far as I know there is no way to do this directly - you have to specify each field you are interested in. 据我所知,无法直接执行此操作-您必须指定您感兴趣的每个字段。

However if you can build up a list of all the fields in the index then you could generate the required aggregations fairly easily. 但是,如果您可以建立索引中所有字段的列表,则可以非常轻松地生成所需的聚合。

So, how to build up that list? 那么,如何建立该列表? I can think of three ways that might work 我能想到的, 可能工作的三种方式

A) build it up by doing some pre-processing before you index each document into ElasticSearch A)在将每个文档索引到ElasticSearch之前,通过进行一些预处理来构建它

B) Use the GET MAPPING api to see what fields have been created by dynamic mapping ( http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html ) B)使用GET MAPPING api来查看通过动态映射创建了哪些字段( http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html

C) Use a Scripted Metric Aggregation and write scripts that build up a de-duped list of fields in the documents ( http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-scripted-metric-aggregation.html ) C)使用脚本化的指标汇总并编写脚本来构建文档中重复数据删除的字段列表( http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics- scripted-metric-aggregation.html

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

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