filter - Exclude empty sub buckets ElasticSearch -


i wrote aggregation query 2 levels:

{   "size": 0,   "aggregations": {     "colors": {       "terms": {         "field": "color"       },       "aggregations": {         "timestamps": {           "date_histogram": {             "field": "timestamp",             "interval": "1m",             "order": {               "_key": "desc"             }           },           "aggregations": {             "timestamps_bucket_filter": {               "bucket_selector": {                 "buckets_path": {                   "counterts": "_count"                 },                 "script": {                   "lang": "expression",                   "script": "counterts == 0"                 }               }             }           }         }       }     }   } } 

as can seen, i'm filtering sub-buckets (timestamps) 0 documents only. problem is, after above filtering there empty buckets @ high level buckets (colors).

for example:

. . . "aggregations": {   "colors": {     "doc_count_error_upper_bound": 12144,     "sum_other_doc_count": 14785757,     "buckets": [       .       .       .,       {         "key": "yellow",    // <<-- empty bucket exclude         "doc_count": 57223,         "timestamps": {           "buckets": [                             // <<-- empty           ]         }       },       .       .       . 

how can exclude colors buckets remain empty timestamps sub-buckets?

thanks in advance!

getting this, i've found out there recent issue , pr adds _bucket_count path buckets_path option aggregation can potentially filter parent bucket based on number of buckets aggregation has. in other words if _bucket_count 0 parent bucket_selector bucket should removed.

this github issue: https://github.com/elastic/elasticsearch/issues/19553


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -