I am trying to use elastic search module in the play framework for searching books and I have the following method to perform the search in the controller which returns me a list of books based upon the search string entered by the user
public static void bookList(String search){
SearchResults<Book> searchResult = ElasticSearch.search(QueryBuilders.queryString(search) , Book.class);
List<Book> bookList = searchResult.objects ;
render(bookList);
}
Now I need to perform pagination on the results obtained . How do I go about doing that using the Java API ?
In Elasticsearch module documentation for Play:
Call ElasticSearch.query() and subsequently set query parameters (eg paging)
So in your case, you want to retrieve j searchresults from i:
SearchResults<Book> searchResult = ElasticSearch.query(QueryBuilders.queryString(search), Book.class).from(i).size(j).fetch();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.