4

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 ?

1 Answer 1

4

In Elasticsearch module documentation for Play:

Call ElasticSearch.query() and subsequently set query parameters (e.g. 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();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.