Iterate over the whole response without size 'predefined' using JAVA API


(anusha) #1

Hi,

How to make my search response to give all the documents matched to the relevant query without using any
setSize(10) with predefined value.
How can I achieve this????

Right now am using :
response = client.prepareSearch(index).setTypes(type)
.setQuery(QueryBuilders.matchAllQuery()).setSize(10).execute()
.actionGet();

Here when I would like to get the complete response and i dont know the size in advance, then how can I achieve the complete response without size declaration. (or) any other way to get the complete data??


(Mark Walkom) #2

Perhaps scan and scroll is what you want? https://www.elastic.co/guide/en/elasticsearch/guide/current/scan-scroll.html


(anusha) #3

Can you provide me the Java API for that scroll operation by including that in the above example or any examples on how to use the scroll with Java API????????


(Colin Goodheart-Smithe) #4

Here is a link to the Java API documentation on using the scroll API: https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/scrolling.html


(system) #5