# Getting java.lang.ArrayIndexOutOfBoundsException while searching

**URL:** <https://discuss.elastic.co/t/getting-java-lang-arrayindexoutofboundsexception-while-searching/35756>\
**Category:** Elasticsearch\
**Created:** [November 27, 2015, 12:24pm UTC](https://discuss.elastic.co/t/getting-java-lang-arrayindexoutofboundsexception-while-searching/35756 "2015-11-27T12:24:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anusha](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@Anusha](https://discuss.elastic.co/u/Anusha)\
**Post date:** [November 27, 2015, 12:24pm UTC](https://discuss.elastic.co/t/getting-java-lang-arrayindexoutofboundsexception-while-searching/35756/1 "2015-11-27T12:24:22Z")

</div>

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????

---

<div class="post-metadata">

**Author:** ![Anusha](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@Anusha](https://discuss.elastic.co/u/Anusha)\
**Post date:** [November 27, 2015, 12:25pm UTC](https://discuss.elastic.co/t/getting-java-lang-arrayindexoutofboundsexception-while-searching/35756/2 "2015-11-27T12:25:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 27, 2015, 12:37pm UTC](https://discuss.elastic.co/t/getting-java-lang-arrayindexoutofboundsexception-while-searching/35756/3 "2015-11-27T12:37:27Z")

</div>

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](https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking_21_search_changes.html#_from_size_limits)

---

<div class="post-metadata">

**Author:** ![Anusha](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@Anusha](https://discuss.elastic.co/u/Anusha)\
**Post date:** [November 27, 2015, 12:46pm UTC](https://discuss.elastic.co/t/getting-java-lang-arrayindexoutofboundsexception-while-searching/35756/4 "2015-11-27T12:46:35Z")

</div>

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????

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 27, 2015, 1:01pm UTC](https://discuss.elastic.co/t/getting-java-lang-arrayindexoutofboundsexception-while-searching/35756/5 "2015-11-27T13:01:44Z")

</div>

It depends on the use case.

- If you want to extract a lot of data, just use [Scan & Scroll](https://www.elastic.co/guide/en/elasticsearch/guide/current/scan-scroll.html)
- 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

---

<div class="post-metadata">

**Author:** ![Anusha](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@Anusha](https://discuss.elastic.co/u/Anusha)\
**Post date:** [December 8, 2015, 10:07am UTC](https://discuss.elastic.co/t/getting-java-lang-arrayindexoutofboundsexception-while-searching/35756/6 "2015-12-08T10:07:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:32pm UTC](https://discuss.elastic.co/t/getting-java-lang-arrayindexoutofboundsexception-while-searching/35756/7 "2017-07-05T23:32:40Z")

</div>


