Elasticsearch aggregation. Order by nested bucket doc_count

后端 未结 2 1206
你的背包
你的背包 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!

提交回复
热议问题