Below is my query. is there any way to access multi-buckets value to manipulate n return the results.
{
"_source": false,
"aggs": {
"nested_dau": {
"nested": {
"path": "dau"
},
"aggs": {
"group_by_month": {
"date_histogram": {
"field": "dau.date",
"calendar_interval": "month"
},
"aggs": {
"sum_loggedin_users": {
"sum": {
"field": "dau.loggedinusers"
}
}
}
},
"group_by_day": {
"date_histogram": {
"field": "dau.date",
"calendar_interval": "day"
},
"aggs": {
"sum_loggedin_users": {
"sum": {
"field": "dau.loggedinusers"
}
}
}
}
}
}
}
}
Maybe?
{
"_source": false,
"aggs": {
"nested_dau": {
"nested": {
"path": "dau"
},
"aggs": {
"group_by_month": {
"date_histogram": {
"field": "dau.date",
"calendar_interval": "month"
},
"aggs": {
"sum_loggedin_users_month": {
"sum": {
"field": "dau.loggedinusers"
}
}
}
},
"group_by_day": {
"date_histogram": {
"field": "dau.date",
"calendar_interval": "day"
},
"aggs": {
"sum_loggedin_users_day": {
"sum": {
"field": "dau.loggedinusers"
}
}
}
},
"ratio": {
"bucket_selector": {
"buckets_path": {
"sumLoggedInMonth": "group_by_month>sum_loggedin_users_month",
"sumLoggedInDay": "group_by_day>sum_loggedin_users_day"
},
"script": "params.sumLoggedInMonth / params.sumLoggedInDay"
}
}
}
}
}
}
getting below exception. How to fix this ? TIA.
{
"error": {
"root_cause": [],
"type": "search_phase_execution_exception",
"reason": "",
"phase": "fetch",
"grouped": true,
"failed_shards": [],
"caused_by": {
"type": "class_cast_exception",
"reason": "class org.elasticsearch.search.aggregations.bucket.nested.InternalNested cannot be cast to class org.elasticsearch.search.aggregations.InternalMultiBucketAggregation (org.elasticsearch.search.aggregations.bucket.nested.InternalNested and org.elasticsearch.search.aggregations.InternalMultiBucketAggregation are in module org.elasticsearch.server@8.3.3 of loader 'app')"
}
},
"status": 500
}
system
(system)
Closed
August 14, 2023, 6:59am
4
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.