Getting java.lang.ArrayIndexOutOfBoundsException while searching

Hi Team,

I am using java api to get the search response,

SearchResponse response = client.prepareSearch(index).setTypes(indextype).setSize(7878151).execute().actionGet();

Am getting the following Exception:

Exception in thread "main" org.elasticsearch.common.util.concurrent.UncategorizedExecutionException: Failed execution
at com.alliance.cachetest.TestMain.getData(
at com.alliance.cachetest.TestMain.main(
Caused by: java.lang.ArrayIndexOutOfBoundsExceptionI am trying to do this SearchResponse response = client.prepareSearch(index).setTypes(indextype).setSize(7878151).execute().actionGet();

Can anyone guide me to solve this issue, is this because if huge data or anything else????

I tried this Even in sense plugin showing the same Exception....

Don't do that!

Actually it's now forbidden in 2.1.


Hello David,

Thanks for response, now what I can do for this to resolve, what changes I need to make in API, can you provide me any example on this????

It depends on the use case.

  • If you want to extract a lot of data, just use Scan & Scroll
  • If you want to display results to your users, I think they can't really read more than 50 results on a single page. So use pagination. After some pages I guess that user will find lesser relevant documents so deep pagination does not make sense.


Thanks David,
Its working with Scan and Scroll API........