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 org.elasticsearch.action.support.AdapterActionFuture.rethrowExecutionException(AdapterActionFuture.java:90)
at org.elasticsearch.action.support.AdapterActionFuture.actionGet(AdapterActionFuture.java:50)
at com.alliance.cachetest.TestMain.getData(TestMain.java:58)
at com.alliance.cachetest.TestMain.main(TestMain.java:30)
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.

Read https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking_21_search_changes.html#_from_size_limits

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.

HTH

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