June 2017
Beginner to intermediate
404 pages
8h 22m
English
Elasticsearch is a full-text search engine, and the results are ordered by the relevance of each document to the query. We will talk about relevance in detail in the Relevance section. In this section, we will only discuss sorting the results based on the existing fields in the document. You can sort the results based on one or more fields. For example, we want to sort the product based on the price. A simple sort query is shown here:
#SortPOST chapter6/_search { "query": { "match": { "product_name": "jacket" } }, "sort": { "unit_price": { "order": "desc" } } }
We can also sort using multiple fields. In the following query, we will sort the results by the price and number of reviews:
POST chapter6/_search ...
Read now
Unlock full access