Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

“order by” translate error #37255

Closed
jjzhang4 opened this issue Jan 9, 2019 · 2 comments
Closed

“order by” translate error #37255

jjzhang4 opened this issue Jan 9, 2019 · 2 comments
Labels
:Analytics/SQL SQL querying

Comments

@jjzhang4
Copy link

jjzhang4 commented Jan 9, 2019

Hi,
I want to order by field ‘’num‘’ in SQL statement, but it doesn't work. The ordered field is group by key “release”.
sql statement:
{"query":"select release,num from (select release,count(distinct id) as num from table group by release) as test1 order by num ASC "}
the translated dsl:
{"size":0,"_source":false,"stored_fields":"none","aggregations":{"groupby":{"composite":{"size":1000,"sources":[{"773":{"terms":{"field":"release","missing_bucket":false,"order":"asc"}}}]},"aggregations":{"780":{"cardinality":{"field":"id"}}}}}}
I want dsl:
{"size":0,"_source":false,"stored_fields":"none","aggregations":{"groupby":{"composite":{"size":1000,"sources":[{"773":{"terms":{"field":"release","missing_bucket":false,"order":{"id":"asc"}}}}]},"aggregations":{"780":{"cardinality":{"field":"release"}}}}}}

@matriv matriv added the :Analytics/SQL SQL querying label Jan 9, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

@matriv
Copy link
Contributor

matriv commented Jan 9, 2019

Hello @jjzhang4,

This is a known missing functionality, currently one cannot order by any aggregate function (count, avg, max, etc.) but only by the grouping key(s). The issue is tracked here: #35118

@matriv matriv closed this as completed Jan 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/SQL SQL querying
Projects
None yet
Development

No branches or pull requests

3 participants