Elasticsearch aggregation. Order by nested bucket doc_count

后端 未结 2 1207
你的背包
你的背包 2021-01-26 19:34

What I want to achieve is aggregation by unique pairs (city, STATE). As per Elasticsearch documentation The terms aggregation does not support collecting terms from multiple

相关标签:
2条回答
  • 2021-01-26 20:06

    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!

    0 讨论(0)
  • 2021-01-26 20:08

    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

    0 讨论(0)
提交回复
热议问题