Reputation: 25
I am trying to get the median excluding zero in elasticsearch. I have the following query: the call_median is getting the median from the field call_cnt. However, we would like to exclude all the zero values of the call_cnt. Please let me know how I can adjust it?
{
"query": {
"bool": {
"filter": [
{
"match": {
"abc": "dfffss"
}
},
{
"range": {
"created_time": {
"gte": 1727827200000,
"lte": 1728259200000
}
}
}
]
}
},
"aggs": {
"group_by_label": {
"terms": {
"field": "rate",
"size": 10000
},
"aggs": {
"api_usage": {
"date_histogram": {
"field": "created_time",
"calendar_interval": "week",
"format": "yyyy-MM-dd"
},
"aggs": {
"total_call_sum": {
"sum": {
"field": "call_cnt"
}
},
"call_median": {
"percentiles": {
"field": "call_cnt",
"percents": [50]
}
}
}
}
}
}
}
}
Upvotes: 0
Views: 22