Elasticsearch aggregation. Order by nested bucket doc_count

不羁岁月 提交于 2019-12-02 05:04:54

I don't believe there is a way to sort on the inner doc_count accross multiple buckets. In ES 2.0 (still in Beta) you'll be able to take action on aggregations but that's not possible in ES 1.x

I've managed to solve the problem by applying transform

"transform": {
  "script": "ctx._source['address']['cityState'] = ctx._source['address']['city'] + ', ' + ctx._source['address']['state']"
}

and then aggregating on the newly added field. Works as expected!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!