S
S
Sergey Vershinin2018-02-26 23:10:38
elasticsearch
Sergey Vershinin, 2018-02-26 23:10:38

Elasticsearch composite aggregation for nested object, is it possible?

Hello.
There is a type in which there is a nested field - this is an object of the id parameter and its values ​​​​(for faceted search)

"parameters": {
        "type": "nested",
        "properties": {
          "id": {
            "type": "integer"
          },
          "values": {
            "type": "keyword"
          }
        }
      }

I want to get data on the number of objects for each parameter value.
GET places/place/_search?size=0
{
  "query": {
    "match_all": {}
  },
  "aggs": {
    "parameters": {
      "nested": {
        "path": "parameters"
      },
      "aggs": {
        "parameters_cnt_i": {
          "terms": {
            "field": "parameters.id",
            "size": 100
          },
          "aggs": {
            "parameters_cnt_v": {
              "terms": {
                "field": "parameters.values",
                "size": 100
              }
            }
          }
        }
      }
    }
  }
}

But this is not very good, I don’t want to overestimate the size, I don’t want to calculate it in advance either.
the documentation says
If you want to retrieve all terms or all combinations of terms in a nested terms aggregation you should use the Composite aggregation
But it doesn't work.
Composite cannot be used in aggs, otherwise nested in source are not visible.
Is there a solution?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question