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

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'
}
}
}
}
})

Welcome to our community! :smiley:

What is lakhs?

1 lakh = 100,000 units. :wink:

You can use:

  • the size and from parameters 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 feature to do deep pagination.
  • the Scroll API if you want to extract a resultset to be consumed by another tool later.

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

As I said: Scroll API.

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