Min_doc_count on lower/lowest level nested aggregation

I have this query with some nested aggregations

{

  • "aggs": {*
  •  "by_date": {*
    
  •     "date_histogram": {*
    
  •        "field": "timestamp",*
    
  •        "interval": "day"*
    
  •     },*
    
  •     "aggs": {*
    
  •        "new_users": {*
    
  •           "filter": {*
    
  •              "query": {*
    
  •                 "match": {*
    
  •                    "action": "USER_ADD"*
    
  •                 }*
    
  •              }*
    
  •           },*
    
  •           "aggs": {*
    
  •              "unique_users": {*
    
  •                 "cardinality": {*
    
  •                    "field": "user"*
    
  •                 }*
    
  •              }*
    
  •           }*
    
  •        }*
    
  •     }*
    
  •  }*
    
  • },*
  • "size": 0*
    }

It yields results that look like this

"aggregations": {

  •  "by_date": {*
    
  •     "buckets": [*
    
  •        {*
    
  •           "key_as_string": "1970-01-07T00:00:00.000Z",*
    
  •           "key": 518400000,*
    
  •           "doc_count": 210,*
    
  •           "new_users": {*
    
  •              "doc_count": 0,*
    
  •              "unique_users": {*
    
  •                 "value": 0*
    
  •              }*
    
  •           }*
    
  •        },*
    
  •        {*
    
  •           "key_as_string": "1970-01-09T00:00:00.000Z",*
    
  •           "key": 691200000,*
    
  •           "doc_count": 6,*
    
  •           "new_users": {*
    
  •              "doc_count": 0,*
    
  •              "unique_users": {*
    
  •                 "value": 0*
    
  •              }*
    
  •           }*
    
  •        },*
    
  •   ......*
    

What I want to happen is apply min_doc_count on the most nested
sub-aggregation such that I don't see zero values for "unique_users" (in
this case) returned.

The issue is that min_doc_count can't be applied to my query other than the
date_histogram at the top level.

Does the ES query language support something like this? Any know
workarounds?

Thanks,
George

--
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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/601928b2-3731-41a1-94bf-b4c039f55817%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.