How To Perform Multiple Aggregation On An Object In Elasticsearch Using Python?
I want to perform date histogram query on my Elasticsearch data which is of the format: datetime,field_obj and field_obj has three fields in it: a,b,c Alongside date histogram aggr
Solution 1:
Good start! You need to do it like this and it will work:
res = es.search(index="demo",body={
"from": 0,
"size": 0,
"query": {
"match_all": {}
},
"aggs": {
"date_avg": {
"date_histogram": {
"field": "datetime",
"interval": "year"
},
"aggs": {
"avg_a": {
"avg": {
"field": "field.a"
}
},
"avg_b": {
"avg": {
"field": "field.b"
}
},
"avg_c": {
"avg": {
"field": "field.c"
}
}
}
}
}
})
Post a Comment for "How To Perform Multiple Aggregation On An Object In Elasticsearch Using Python?"