# Want to find all document in elastic search in Node JS using aggregation

**URL:** <https://discuss.elastic.co/t/want-to-find-all-document-in-elastic-search-in-node-js-using-aggregation/273281>\
**Category:** Elasticsearch\
**Created:** [May 18, 2021, 12:13pm UTC](https://discuss.elastic.co/t/want-to-find-all-document-in-elastic-search-in-node-js-using-aggregation/273281 "2021-05-18T12:13:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anjali\_Gupta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anjali_gupta/32/76976_2.png) [@Anjali\_Gupta](https://discuss.elastic.co/u/Anjali_Gupta)\
**Post date:** [May 18, 2021, 12:13pm UTC](https://discuss.elastic.co/t/want-to-find-all-document-in-elastic-search-in-node-js-using-aggregation/273281/1 "2021-05-18T12:13:48Z")

</div>

Here is my code, i have lakhs of document in transactions\_development index and in below code I am getting only 10 hits inside body but I want to fetch lakhs of hits

const totalDebited = await esClient.search({  
index: 'transactions\_development',  
body: {  
query: {  
bool: {  
must: {  
match\_all: {}  
},  
filter: [{ term: { actionee\_id: { value: param.dataValues.actioneeId } } }, { terms: { transaction\_type: ['bet', 'bet\_non\_cash'] } }]  
}  
},  
aggs: {  
total\_bet\_amount: {  
sum: {  
field: 'player\_details.deducted\_amount'  
}  
}  
}  
}  
})

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 20, 2021, 1:50am UTC](https://discuss.elastic.co/t/want-to-find-all-document-in-elastic-search-in-node-js-using-aggregation/273281/2 "2021-05-20T01:50:12Z")

</div>

Welcome to our community! 😃

What is lakhs?

---

<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:** [May 20, 2021, 4:40am UTC](https://discuss.elastic.co/t/want-to-find-all-document-in-elastic-search-in-node-js-using-aggregation/273281/3 "2021-05-20T04:40:20Z")

</div>

1 lakh = 100,000 units. 😉

---

<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:** [May 20, 2021, 4:40am UTC](https://discuss.elastic.co/t/want-to-find-all-document-in-elastic-search-in-node-js-using-aggregation/273281/4 "2021-05-20T04:40:50Z")

</div>

You can use:

- the [`size` and `from` parameters](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-from-size.html) to display by default up to 10000 records to your users. If you want to change this limit, you can change `index.max_result_window` setting but be aware of the consequences (ie memory).
- the [search after](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-search-after.html) feature to do deep pagination.
- the [Scroll API](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html) if you want to extract a resultset to be consumed by another tool later.

---

<div class="post-metadata">

**Author:** ![Anjali\_Gupta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anjali_gupta/32/76976_2.png) [@Anjali\_Gupta](https://discuss.elastic.co/u/Anjali_Gupta)\
**Post date:** [May 20, 2021, 4:48am UTC](https://discuss.elastic.co/t/want-to-find-all-document-in-elastic-search-in-node-js-using-aggregation/273281/5 "2021-05-20T04:48:27Z")

</div>

ok, but If I want to export all documents in pdf file then how I achieve that using elastic search. Because max 10000 records I am able to fetch in one go and In my index very big data is stored which may be more then 10 lakhs

---

<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:** [May 20, 2021, 7:53am UTC](https://discuss.elastic.co/t/want-to-find-all-document-in-elastic-search-in-node-js-using-aggregation/273281/6 "2021-05-20T07:53:37Z")

</div>

As I said: 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:** [June 17, 2021, 7:53am UTC](https://discuss.elastic.co/t/want-to-find-all-document-in-elastic-search-in-node-js-using-aggregation/273281/7 "2021-06-17T07:53:59Z")

</div>

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