GET /civile/_search
{
"size": 0,
"query": {
"match": {
"distretto": "MI"
}
},
"aggs": {
"our_buckets": {
"composite": {
"size": 1000,
"sources": [
{ "codiceoggetto": { "terms": { "field": "codiceoggetto.keyword", "order": "desc" } } }
]
}
}
}
}
我的Elasticsearch查询通过distretto =“MI”匹配文档。当size = 0时,我隐藏结果。
但最重要的是我定义了我们的_buckets聚合,它返回1000个键,并对codiceoggetto.keyword字段进行“分组”。
现在我想按doc_count对我的桶结果排序!我该怎么做?
这里的回应
{
"took" : 20,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 10000,
"relation" : "gte"
},
"max_score" : null,
"hits" : [ ]
},
"aggregations" : {
"our_buckets" : {
"after_key" : {
"codiceoggetto" : "010001"
},
"buckets" : [
{
"key" : {
"codiceoggetto" : "490999"
},
"doc_count" : 3
},
{
"key" : {
"codiceoggetto" : "481312"
},
"doc_count" : 1
},
1条答案
按热度按时间d7v8vwbk1#
可以使用bucket_sort执行此操作