# ELK: How do I retrieve more than 10000 results using Elastic-search in node js

**URL:** <https://discuss.elastic.co/t/elk-how-do-i-retrieve-more-than-10000-results-using-elastic-search-in-node-js/121172>\
**Category:** Elasticsearch\
**Created:** [February 23, 2018, 6:07am UTC](https://discuss.elastic.co/t/elk-how-do-i-retrieve-more-than-10000-results-using-elastic-search-in-node-js/121172 "2018-02-23T06:07:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jasso](https://avatars.discourse-cdn.com/v4/letter/j/d78d45/32.png) [@Jasso](https://discuss.elastic.co/u/Jasso)\
**Post date:** [February 23, 2018, 6:07am UTC](https://discuss.elastic.co/t/elk-how-do-i-retrieve-more-than-10000-results-using-elastic-search-in-node-js/121172/1 "2018-02-23T06:07:25Z")

</div>

```auto
function getElasticData(endTime, startTime) {
     return new Promise(function (resolve, reject) {
      elasticClient.search({
             index: 'logstash-*',
             type: 'callEnd',
             size: 10000,
             body: {
                 query: {

                     range: {
                         "@timestamp": {
                             "gte": startTime,
                             "lte": endTime
                         }

                     }
                 }
             }
         }, function (error, response, status) {
             if (error) {
                 reject(error);
             }
             else {
                 resolve(response);
             }
         })

     });
 }

```

---

<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:** [February 23, 2018, 6:29am UTC](https://discuss.elastic.co/t/elk-how-do-i-retrieve-more-than-10000-results-using-elastic-search-in-node-js/121172/2 "2018-02-23T06:29:46Z")

</div>

Please format your code, logs or configuration files using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.  
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.  
Please update your post.

To extract lot of data in a consistent way, use the scroll API

---

<div class="post-metadata">

**Author:** ![Jasso](https://avatars.discourse-cdn.com/v4/letter/j/d78d45/32.png) [@Jasso](https://discuss.elastic.co/u/Jasso)\
**Post date:** [February 23, 2018, 7:19am UTC](https://discuss.elastic.co/t/elk-how-do-i-retrieve-more-than-10000-results-using-elastic-search-in-node-js/121172/3 "2018-02-23T07:19:40Z")

</div>

I have changed the code and removed the console.log

Thanks,  
Jasso

---

<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:** [February 23, 2018, 7:32am UTC](https://discuss.elastic.co/t/elk-how-do-i-retrieve-more-than-10000-results-using-elastic-search-in-node-js/121172/4 "2018-02-23T07:32:33Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![Jasso](https://avatars.discourse-cdn.com/v4/letter/j/d78d45/32.png) [@Jasso](https://discuss.elastic.co/u/Jasso)\
**Post date:** [February 24, 2018, 12:32pm UTC](https://discuss.elastic.co/t/elk-how-do-i-retrieve-more-than-10000-results-using-elastic-search-in-node-js/121172/5 "2018-02-24T12:32:15Z")

</div>

Hi dadoonet,  
I am using nodejs and querying in elasticsearch. I want the output that matches the conditions. But, I am not able to get the output more than 10,000 records and below the error message I'm getting Result window is too large, from + size must be less than or equal to: [10000] but was [20000]. 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]. please let me know how we can achieve it

---

<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:** [February 24, 2018, 1:31pm UTC](https://discuss.elastic.co/t/elk-how-do-i-retrieve-more-than-10000-results-using-elastic-search-in-node-js/121172/6 "2018-02-24T13:31:01Z")

</div>

I already answered you with:

> To extract lot of data in a consistent way, use the scroll API

The error message says it all as well:

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

Is there something unclear?

---

<div class="post-metadata">

**Author:** ![Jasso](https://avatars.discourse-cdn.com/v4/letter/j/d78d45/32.png) [@Jasso](https://discuss.elastic.co/u/Jasso)\
**Post date:** [February 24, 2018, 1:54pm UTC](https://discuss.elastic.co/t/elk-how-do-i-retrieve-more-than-10000-results-using-elastic-search-in-node-js/121172/7 "2018-02-24T13:54:38Z")

</div>

Ok thanks dadoonet. Everything is clear now

---

<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:** [March 24, 2018, 1:55pm UTC](https://discuss.elastic.co/t/elk-how-do-i-retrieve-more-than-10000-results-using-elastic-search-in-node-js/121172/8 "2018-03-24T13:55:28Z")

</div>

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