Pagination
Search API returns number of results based on the limit in search request. If there're more results available, search response will return paginationContext
which can be used to get results for next page. Refer to following example code for pagination.
Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 | EntityClient entityClient = EntityService.getClient();
EntitySearchResponse page1 = entityClient.searchRequest()
.setLocation(37.78509, -122.41988)
.setQuery("food")
.setLimit(5)
.execute();
// get search results for next page
if (page1.getPaginationContext() != null && page1.getPaginationContext().getNextPageContext() != null) {
EntitySearchResponse page2 = entityClient.searchRequest()
.setPageContext(page1.getPaginationContext().getNextPageContext())
.execute();
assert page2.getResults().size() > 0;
}
|