June 2017
Beginner to intermediate
404 pages
8h 22m
English
In the previous section, we learned about the basic query in Elasticsearch. In this section, we will discuss how to limit the number of results in the response. Pagination is supported using the from and size fields in the query. The default page size is 10. A query to limit the number of documents to 2 is shown here:
#Pagination POST chapter6/_search { "from" : 0, "size" : 2, "query" : { "match" : { "product_name" : "wool jacket" } } }
In the preceding query, we are getting the top 2 results. If the page size is 10, to get the third page, we would use from as 20 and size as 10. Pagination in a distributed system is very expensive when compared to a traditional database. The data belonging to an index is spread across multiple ...
Read now
Unlock full access