Search API sortedit

Sort your results in an order other than document score.

Using sort will override the default relevance scoring method.

A special sorting field name is available, _score, to order by relevance.

If a sort parameter is not given, results will be ordered by descending relevance.

Type Sorting

text

Yes, alphanumerically.

number

Yes, numerically.

date

Yes, historically.

geolocation

No

Sortingedit

Sort on one field.

Example - Sorting alphanumerically by the title of the national park.

curl -X GET 'https://[instance id].ent-search.[region].[provider].cloud.es.io/api/as/v1/engines/national-parks-demo/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-soaewu2ye6uc45dr8mcd54v8' \
-d '{
  "query": "everglade",
  "sort": {
    "title": "desc"
  }
}'

Sorting on Multiple Fieldsedit

Sort on multiple fields by using an array.

Example - Sorting by document score and tie-breaking by the title of the national park.

curl -X GET 'https://[instance id].ent-search.[region].[provider].cloud.es.io/api/as/v1/engines/national-parks-demo/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-soaewu2ye6uc45dr8mcd54v8' \
-d '{
  "query": "everglade",
  "sort": [
    { "_score": "desc" },
    { "title": "desc" }
  ]
}'

Errorsedit

sort

If the field used to sort is not in the schema and is not _score. If the sort JSON object has more than one key.