Please explain the logic of the query translation from sql in kibana console. The most confusing is "order" : "asc", while i request desc.
The numbers "10985", and "11030" also looks very strange. If I re-run translation these numbers are changing.
I make a query translation:
POST _sql/translate
{
"query": "SELECT day_of_week, avg(taxful_total_price) FROM kibana_sample_data_ecommerce WHERE customer_id = 52 GROUP BY day_of_week ORDER BY avg(taxful_total_price) DESC LIMIT 2"
}
Translation:
{
"size" : 0,
"query" : {
"term" : {
"customer_id" : {
"value" : 52,
"boost" : 1.0
}
}
},
"_source" : false,
"stored_fields" : "_none_",
"aggregations" : {
"groupby" : {
"composite" : {
"size" : 1000,
"sources" : [
{
"10985" : {
"terms" : {
"field" : "day_of_week",
"missing_bucket" : true,
"order" : "asc"
}
}
}
]
},
"aggregations" : {
"11030" : {
"avg" : {
"field" : "taxful_total_price"
}
}
}
}
}
}
Regarding the changing number, they are only the names of the aggregation; as if you would use the "AS 11030" in sql. It allows you to use the aggregation in other aggregation by refeering to its name. It is mandatory to have a name for an aggregation in the structure of the ES query. Perhaps it is normal behavior of the translation to randomly name the aggregations with numbers. It should not have incidence over the results of the query or it's behavior.