- App Search Guide: other versions:
- Installation
- Getting started
- Authentication
- Limits
- Security & Users
- Guides
- Analytics Tags
- Crawl web content
- Curations
- Facets
- Hierarchical Facets
- Indexing Documents
- Language Optimization
- Log settings
- Meta Engines
- Precision tuning (beta)
- Query Suggestions
- Reference UI
- Relevance Tuning
- Result Settings
- Result Suggestions
- Role Based Access Control
- Sanitization, Raw or Snippet
- Search
- Synonyms
- View web crawler events logs
- Web crawler (beta)
- Web crawler (beta) FAQ
- Web crawler (beta) reference
- Web crawler (beta) events logs reference
- API Reference
- Analytics APIs
- Analytics clicks API
- Analytics counts API
- Analytics queries API
- API logs API
- Click API
- Credentials API
- Curations API
- Documents API
- Engines API
- Log settings API
- Multi search API
- Query suggestion API
- Schema API
- Search API
- Search API boosts
- Search API facets
- Search API filters
- Search API group
- Search API precision (beta)
- Search API result fields
- Search API search fields
- Search API sort
- Search API analytics tags
- Search settings API
- Source engines API
- Synonyms API
- Web crawler (beta) API reference
- API Clients
- Configuration
- Troubleshooting
IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Search API sort
edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.
Search API sort
editSort 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 |
---|---|
|
Yes, alphanumerically. |
|
Yes, numerically. |
|
Yes, historically. |
|
No |
Sorting
editSort 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 Fields
editSort 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" } ] }'
Errors
edit
|
If the field used to sort is not in the schema and is not |
On this page
Was this helpful?
Thank you for your feedback.