How to guarantee percentage of result in multi_match search

I have a search using multi_match that returns products from multiple stores

there is a business logic that i need to implement, which is:

ensure that products from certain stores must appear on each pagination (30 items)

i.e. I have two stores that need to have at least 10% of their products on each page

should look like this:
store_ids = [5, 6]

results:
[1, 1, 1, 1, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 6, 6 , 1, 1, 1, 1, 1,]

it depends on the result, that is, on the amount of results it finds

Is there any way to get this result?

Not directly from Elasticsearch, no. You will need to run a query and then sort them accordingly in your code.

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