sudo-suhas/elastic-builder

Sort issue on Bucketsort Agg

ronycohen opened this issue · 2 comments

Hello !

The example :

const reqBody = esb.requestBodySearch() .agg( esb.bucketSortAggregation('sort') **.sort([ esb.sort('user', 'desc') ])** .from(5) .size(10) ) );

is Wrong.

the result create a sort like :

"sort": [
{
"user": "desc"
}
],

What is needed in Elastic Doc : https://www.elastic.co/guide/en/elasticsearch/reference/master/search-aggregations-pipeline-bucket-sort-aggregation.html

                    "sort": [
                      {"user": {"order": "desc"}}
                    ],

Best Regards !

My understanding is that {"order": "desc"} is a short-hand for {"user": {"order": "desc"}} based on this - https://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-body.html#request-body-search-sort

Have you tried to execute a query with the short-hand and does it not work?

Closing due to inactivity.