0

In my product index I have 60K records, I'm running a match query with from, size params. by default, ES support a 10k record search so I have increased it to 60k.

My issue is I'm already passing size param from API & I want to search in 60K records with the same pagination size param.

So how I can match 60k records with my pagination size param.

Here is my code:

const query = {
    query: {
        match: {
            name: {
                query: req.text
            }
        }
    }
}

const { body: { hits } } = await esclient.search({
    from: req.skip || 0,
    size: req.offset || 50,
    index: productsIndex,
    type: productsType,
    body: query,
});

here code with 60K size:

const query = {
    query: {
        match: {
            name: {
                query: req.text
            }
        }
    },
    size:60000
}

in my query, if I use size=60K, I'm getting 20 records (without that I'm getting 12 records) but I can't use pagination params.

zulqarnain
  • 1,536
  • 4
  • 26
  • 44
  • Do you have any errors when you do the search? As I see, you have already aware of `index.max_result_window` setting. Could you give more detail to understand the real problem here? Do you want to see the number of matched products? – hkulekci Jan 29 '22 at 21:43

1 Answers1

0

If I get your question correctly,

size parameter is the number of hits/documents you want in response. It's not that elasticsearch will process your query only in first size number of documents. 10K is the maximum number of documents you can get in response. If you specify size more than 10K, elastic search will give you an error like this. ES error

Without worring about the above problem, use from and size as the parameters for your pagination.

  • you can modify limit using `"max_result_window": 60000`, that's my issue if use **size** 60k getting 20 records, otherwise 12. – zulqarnain Jan 28 '22 at 10:47