# Search API Limits

**URL:** https://discuss.elastic.co/t/search-api-limits/152491
**Category:** Elasticsearch
**Created:** [October 15, 2018, 12:31pm UTC](https://discuss.elastic.co/t/search-api-limits/152491 "2018-10-15T12:31:30Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![bakko91](https://avatars.discourse-cdn.com/v4/letter/b/c89c15/32.png) [@bakko91](https://discuss.elastic.co/u/bakko91)
#### Post date: [October 15, 2018, 12:31pm UTC](https://discuss.elastic.co/t/search-api-limits/152491/1 "2018-10-15T12:31:31Z")

</div>

Hi all!

I'm new to elastic and also new to the forum, so please forgive me if I ask something stupid or wrong.  
I have a problem using Search API of Java High Level REST Client because I'm trying to make a request with "from" parameter set with value 1000000000 and the "size" parameter equal to 100 (this is a test case obviously), but when i try to make the search request I receive the following error:

[org.elasticsearch.client.ResponseException: method [POST], host [[http://127.0.0.1:9200](http://127.0.0.1:9200)], URI [/test\_idx/test\_type/\_search?typed\_keys=true&ignore\_unavailable=false&expand\_wildcards=open&allow\_no\_indices=true&search\_type=query\_then\_fetch&batched\_reduce\_size=512], status line [HTTP/1.1 500 Internal Server Error]  
{"error":{"root\_cause":[{"type":"query\_phase\_execution\_exception","reason":"Result window is too large, from + size must be less than or equal to: [10000] but was [1000000100]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max\_result\_window] index level setting."}],"type":"search\_phase\_execution\_exception","reason":"all shards failed","phase":"query","grouped":true,"failed\_shards":[{"shard":0,"index":"test\_idx","node":"jifB2vzCRM6N7aOb1c8YSg","reason":{"type":"query\_phase\_execution\_exception","reason":"Result window is too large, from + size must be less than or equal to: [10000] but was [1000000100]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max\_result\_window] index level setting."}}]},"status":500}]

I know that elastic has a default value of 10000 for max\_result\_window, but in this case I want 100 elements (as specified with the size parameter) starting from 1000000000. Is my reasoning wrong? Could you tell me if maybe I don't understood well how "from" and "size" works?

Thank you in advance

---

<div class="post-metadata">

### Author: ![klof](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/klof/32/31590_2.png) [@klof](https://discuss.elastic.co/u/klof)
#### Post date: [October 15, 2018, 12:53pm UTC](https://discuss.elastic.co/t/search-api-limits/152491/2 "2018-10-15T12:53:18Z")

</div>

You are right, and as it's mentioned in the documentation there's a limitation of 10000.  
But it doesn't matter the number of size, because the limitation is on the addition of : **from + size**

> Note that `from` + `size` can not be more than the `index.max_result_window` index setting which defaults to 10,000

---

<div class="post-metadata">

### Author: ![bakko91](https://avatars.discourse-cdn.com/v4/letter/b/c89c15/32.png) [@bakko91](https://discuss.elastic.co/u/bakko91)
#### Post date: [October 15, 2018, 12:59pm UTC](https://discuss.elastic.co/t/search-api-limits/152491/3 "2018-10-15T12:59:07Z")

</div>

@klof Ok but assume that I have 1000000 documents in my index and I want to retrieve the last 10 elements, how can I do if from+size must be less then the aforementioned limitation?

Thanks

---

<div class="post-metadata">

### Author: ![klof](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/klof/32/31590_2.png) [@klof](https://discuss.elastic.co/u/klof)
#### Post date: [October 15, 2018, 1:45pm UTC](https://discuss.elastic.co/t/search-api-limits/152491/4 "2018-10-15T13:45:37Z")

</div>

Maybe you could :

- use the scroll API, to parse all the results.  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html)

- Otherwise maybe you will have to query differently (sort desc?).

- Or create multiple small indices, to you would query easier?

I don't know if these approaches can be applied in your case?

---

<div class="post-metadata">

### Author: ![bakko91](https://avatars.discourse-cdn.com/v4/letter/b/c89c15/32.png) [@bakko91](https://discuss.elastic.co/u/bakko91)
#### Post date: [October 18, 2018, 7:49am UTC](https://discuss.elastic.co/t/search-api-limits/152491/5 "2018-10-18T07:49:01Z")

</div>

I think that scroll API is the only solution. Thank you for your help!

---

<div class="post-metadata">

### Author: ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)
#### Post date: [October 18, 2018, 2:14pm UTC](https://discuss.elastic.co/t/search-api-limits/152491/6 "2018-10-18T14:14:31Z")

</div>

There is also [search\_after](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-search-after.html). Scroll might be what you want though, because it has a consistent snapshot.

---

<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: [November 15, 2018, 2:14pm UTC](https://discuss.elastic.co/t/search-api-limits/152491/7 "2018-11-15T14:14:32Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
