ElasticSearch sort order for multiple fields

What is the best way to specify the sort order in ElasticSearch for multiple fields? The query string format does not work at all:

http://elasticsearch_url/index/_search?sort=field1:asc&sort=field2:desc&size=100

First you need to sort by field 1, then by field2, but only one of the fields seems to be sorted correctly. Full notations work better, but the first entries have the wrong search order:

curl -s -XGET http://elasticsearch_url/index/_search -d '
{
    "sort": [
        { "field1": { "order": "desc" }},
        { "field2": { "order": "desc" }}
    ],
    "size": 100
}'
+4
source share
1 answer

Apparently, the second, full notation works better.

, URL-, ElasticSearch . , URL ElasticSearch .

+2

Source: https://habr.com/ru/post/1584057/


All Articles