- Notifications
You must be signed in to change notification settings - Fork 25.6k
Closed
Labels
:Analytics/AggregationsAggregationsAggregationsenhancement"" muted="" aria-describedby="MDU6TGFiZWwyMzE3NA==-tooltip :R5b96b:">>enhancementTeam:AnalyticsMeta label for analytical engine team (ESQL/Aggs/Geo)Meta label for analytical engine team (ESQL/Aggs/Geo)
Description
Currently both TopHits and TopMetrics aggs don't allow the use of bucket selector which in turn
doesn't allow the translation of an SQL query with a HAVING clause on such aggregations to be used:
e.g.:
SELECT gender, FIRST(salary, birth_date) as first FROM test_emp GROUP BY gender HAVING first > 10000 ORDER BY gender This query would translate to something like this in query DSL:
{ "aggregations": { "groupby": { "composite": { "size": 1000, "sources": [ { "754ec7e7": { "terms": { "field": "gender", "missing_bucket": true, "order": "asc" } } } ] }, "aggregations": { "d08ba905": { "top_metrics": { "metrics": { "field": "salary" }, "sort": { "birth_date": "asc" }, "size": 10 } }, "having.d08ba905": { "bucket_selector": { "buckets_path": { "a0": "d08ba905" }, "script": { "source": "InternalQlScriptUtils.nullSafeFilter(InternalQlScriptUtils.gt(InternalQlScriptUtils.nullSafeCastNumeric(params.a0,params.v0),params.v1))", "lang": "painless", "params": { "v0": "INTEGER", "v1": 1000 } }, "gap_policy": "skip" } } } } } } which throws:
"caused_by": { "type": "aggregation_execution_exception", "reason": "buckets_path must reference either a number value or a single value numeric metric aggregation, got: [InternalTopHits] at aggregation [d08ba905]" } Metadata
Metadata
Assignees
Labels
:Analytics/AggregationsAggregationsAggregationsenhancement"" muted="" aria-describedby="MDU6TGFiZWwyMzE3NA==-tooltip :Ra5pmb:">>enhancementTeam:AnalyticsMeta label for analytical engine team (ESQL/Aggs/Geo)Meta label for analytical engine team (ESQL/Aggs/Geo)