Sorting on elastic search with node js
Try this instead:
elasticClient.search({ index: indexName, type: id, body: { sort: [{ "_uid": { "order": "desc" } }], size: 1, query: { match_all: {}} } })
This also works with the square brackets around it so you can add more than one sort criteria like ['_uid:desc', 'id:asc']
elasticClient.search({ index: indexName, sort: ['_uid:desc'], type: id, body: { size: 1, query: { match_all: {}} } })
This also works :
elasticClient.search({ index: indexName, sort: '_uid:desc', type: id, body: { size: 1, query: { match_all: {}} } })