Hi, If a filter
or filters
aggregation is applied above serial_diff
aggregation, Elasticsearch is returning error.
Elasticsearch version: v5.6.4
Please find below ES query:
{
"size": 0,
"aggs": {
"years": {
"date_histogram": {
"field": "order_date",
"interval": "year"
},
"aggs": {
"total_sales": {
"sum": {
"field": "sales"
}
},
"in_california": {
"filter": {
"term": {
"state": "california"
}
},
"aggs": {
"total_sales": {
"sum": {
"field": "sales"
}
},
"__serial_diff__": {
"serial_diff": {
"gap_policy": "insert_zeros",
"buckets_path": "total_sales"
}
}
}
}
}
}
}
}
This is the error that is being returned:
{
"error": {
"root_cause": [],
"type": "search_phase_execution_exception",
"reason": "",
"phase": "fetch",
"grouped": true,
"failed_shards": [],
"caused_by": {
"type": "class_cast_exception",
"reason": "org.elasticsearch.search.aggregations.bucket.filter.InternalFilter cannot be cast to org.elasticsearch.search.aggregations.InternalMultiBucketAggregation"
}
},
"status": 503
}{
"error": {
"root_cause": [],
"type": "search_phase_execution_exception",
"reason": "",
"phase": "fetch",
"grouped": true,
"failed_shards": [],
"caused_by": {
"type": "class_cast_exception",
"reason": "org.elasticsearch.search.aggregations.bucket.filter.InternalFilter cannot be cast to org.elasticsearch.search.aggregations.InternalMultiBucketAggregation"
}
},
"status": 503
}
The use case is: I want total_sales
of all states, total_sales_of_california
and increase
in total_sales_of_california
from previous year.