Null handing in facets/filters

It would be nice if we could use null value in term/terms filters and
facets as indicator we want to filter/facet on missing values

for example following filter will return docs with country == canada or
blank (bool of terms and missing filter)

country:['CANADA', null]

While it could easily be done combining terms and missing filters it is a
nice shortcut
More importantly in facet_filter null will be acting as a first class
citizen allowing us to get stats using terms_stats facets for missing filed

But the truth is that I would not be considering the functionality above if
terms_stats facet would have been consistent in calculating stats for
"missing" and "other" just like terms facet does with counts but
unfortunately it completely disregards them. I was working around it by
using statistical facet in the same query and using it to calculate "other

  • missing" as difference between its total and sum of the total of each
    term produced by my terms_stats facets. Unfortunately it does not let me
    distinguish between "missing" and "other" which is very important for us to
    produce consistent and complete charts. If use facet_filter would give me
    stats for null I could have combined terms_stats query on unfiltered terms
    with the same facet with facet_filter for null value :slight_smile: It is ugly but so
    far I have not come up with any approach to calculate "missing" and "other"
    stats in terms_stats facet

You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit