elasticsearch_dsl: Generate multiple buckets in aggregation
I want to generate this: GET /packets-2017-09-25/_search { "size": 0, "query": { "match": { "transport_protocol": "tcp" } }, "aggs": { "clients": { "terms": { "field": "layers.ip.src.keyword", "size": 1000, "order":{ "num_servers.value":"desc" } }, "aggs": { "num_servers": { "cardinality": { "field": "layers.ip.dst.keyword", "precision_threshold" : 40000 } }, "server_list": { "terms": { "field": "layers.ip.dst.keyword" } } } } } } i.e I want two buckets (num_servers) and (server_list) under clients. I am trying the below piece of code, which errors out: def get_streams_per_client(proto='tcp',