# Fetching large data from Elasticsearch in Node.js

**URL:** <https://discuss.elastic.co/t/fetching-large-data-from-elasticsearch-in-node-js/195352>\
**Category:** Elasticsearch\
**Created:** [August 15, 2019, 2:09pm UTC](https://discuss.elastic.co/t/fetching-large-data-from-elasticsearch-in-node-js/195352 "2019-08-15T14:09:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![purple](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/purple/32/44578_2.png) [@purple](https://discuss.elastic.co/u/purple)\
**Post date:** [August 15, 2019, 2:09pm UTC](https://discuss.elastic.co/t/fetching-large-data-from-elasticsearch-in-node-js/195352/1 "2019-08-15T14:09:49Z")

</div>

I am fetching about `60,000` documents from an index `ABC` in Elasticsearch (v7) through their Node.js client. I tried using their recommended Scroll API but it took almost `20s` to do so. Next, I increased the `max_window_size` of the index `ABC` to `100,000` (from the default `10,000` ) and the query took `5s` .

I am running Elasticsearch v7 on a 8-core, 32GB-RAM machine (1-node cluster). I am not performing any aggregations and my query is just a simple GET request to fetch all documents from the index `ABC` . Is there any way to speed this up to less than one second through their Node.js client?

My code in Express

```auto
const { body } = await client.search({
          index: 'ABC',
          size: 60000,
          body: {
            query: {
              match_all: {}
            }
          },
        });
        res.send(body.hits.hits);

```

If there's no other way to cut the time down, should I cache the entire response in memory and let the UI read from it rather than hitting ES directly (the data only updates once per day, I might not need to perform cache validations). Should I look into Redis for this?

---

<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:** [September 12, 2019, 2:09pm UTC](https://discuss.elastic.co/t/fetching-large-data-from-elasticsearch-in-node-js/195352/2 "2019-09-12T14:09:50Z")

</div>

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