Filtering buckets from aggs

Hi, I am trying to exclude all buckets that are contained in another buckets 'term' field. For example

              {
                "key": "1",
                "doc_count": 2
              },
              {
                "key": "12",
                "doc_count": 2
              },
              {
                "key": "123",
                "doc_count": 2
              },
              {
                "key": "1234",
                "doc_count": 2
              },
              {
                "key": "12345",
                "doc_count": 1
              },
}``

I want the output to be 

``` "buckets":[ {
            "key" : "12345"
            "doc_count" : 1
}]
``
as it contains all other buckets. How can I do this using aggs or filters?

Please be patient. The forum is manned by volunteers and it is now weekend. Also please do not address specific individuals unless they have already responded to your query.

Please be patient. The forum is manned by volunteers and it is now weekend. Also please do not address specific individuals unless they have already responded to your query.

okay, sorry, I am new to this service;D

can u help me?:smiley:

No, unfortunately not. I am on my mobile and the poor connection caused me to post twice.

These all seem to be unrelated terms. How do you determine that one bucket is contained in another? What exactly is it you are trying to achieve?

I am trying to filter these buckets into one, so that the bucket which is contained by another not showed in final result, is it possible?

I still do not understand what you are trying to achieve, so will probably not be able to help.

I don't think that is possible as ES treats them all as separate buckets.

1 Like

Hi, thank you for your reply.. How do you think, can ES filter from query if we consider that the inputs are not buckets, but just documents? So that, from the filter query we receive the document that is not contained by other document? @warkolm

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