[英]elastic search aggregate doesn't return data
It possible that aggregate function returns data instead of count? 聚合函数可能返回数据而不是计数吗?
Right now I get: 现在我得到:
array (size=3)
'doc_count_error_upper_bound' => int 0
'sum_other_doc_count' => int 0
'buckets' =>
array (size=2)
0 =>
array (size=2)
'key' => int 15
'doc_count' => int 2
1 =>
array (size=2)
'key' => int 14
'doc_count' => int 1
But this is useless cause I need the actual data that represents this doc_count of 2 and doc_count of 1 但这是没有用的,因为我需要代表doc_count为2和doc_count为1的实际数据
I'm using elastica.io 我正在使用elastica.io
You can make a query like the following and use top_hits aggregations to get the document source. 您可以进行如下查询,并使用top_hits聚合来获取文档源。
{
"aggs": {
"terms_aggregation": {
"terms": {
"field": "anyfield",
"size": 10
},
"aggs": {
"gruped_result": {
"top_hits": {
"size": 100
}
}
}
}
}
}
I think maybe something like this in your php client 我认为您的php客户端可能是这样的
$termsAgg = new Terms("anyfields");
$termsAgg->setField("anyfield");
$statsAgg = new TopHits();
$statsAgg->setSize(100);
$termsAgg->addAggregation($statsAgg);
$index = $elasticaClient->getIndex('someindex');
$buckets = $index->search($query)->getAggregation("anyfields");
I referred this example for Sub-aggregations on official page 我在官方页面上将这个示例用于子聚合
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.