Terms aggregation Java API with missing

(Ben) #1


I am trying to build a Terms bucket aggregation that also includes documents with the term missing. What I'm finding is, without adding a .missing(), as you would expect, any documents missing the term are not included in the results. However, if add the .missing("Unknown") clause to the builder I then the only bucket I get back is for documents with that term missing. How do I combine the two to get both?

Interestingly, if I set a breakpoint in the code and cut and paste the generated JSON into Postman and fire it off - I get the data back as I would expect: with all terms and the missing one included as 'Unknown'.

Any pointers would be much appreciated. Here is the code I am trying:

    AggregationBuilder aggregation =
                    .missing("Unknown")  <-- With this added only missing are returned
                                    .extendedBounds(new ExtendedBounds("now-" + time + "M", "now"))


(Ben) #2

Turns out I was looking in the wrong place and my index selection routine was at fault! You do feel a fool don't you.

(system) #3

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