Terms aggregations exclude the key of parent

   GET posts/_search
    {
      "size": 0,
      "aggs": {
        "hashtags": {
          "terms": {
            "field": "hashtags",
            "size": 10
          },
          "aggs": {
            "tagalongs": {
              "terms": {
                "field": "hashtags",
                "size": 10
              }
            }
          }
        }
      }
    }

With this query you get results with the same key as the top result. Like the following example.

    "aggregations" : {
        "hashtags" : {
          "doc_count_error_upper_bound" : 1991,
          "sum_other_doc_count" : 865940,
          "buckets" : [
            {
              "key" : "love",
              "doc_count" : 12542,
              "tagalongs" : {
                "doc_count_error_upper_bound" : 973,
                "sum_other_doc_count" : 264137,
                "buckets" : [
                  {
                    "key" : "love",
                    "doc_count" : 12542
                  },

Is there an easy and performant way to exclude the key of the parent?

@abdon Do you have any ideas?

No, I don't know of an obvious way to let Elasticsearch do it. I'd think the easiest way to do this would be client-side?

Oke no sweat, I will give back one more and exclude the same key. But I thaught this could maybe possible within the core.

Happy weekend!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.