# Interleaving search results in ElasticSearch

**URL:** https://discuss.elastic.co/t/interleaving-search-results-in-elasticsearch/382063
**Category:** Elasticsearch
**Created:** [September 18, 2025, 4:40pm UTC](https://discuss.elastic.co/t/interleaving-search-results-in-elasticsearch/382063 "2025-09-18T16:40:50Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![malaranjo](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@malaranjo](https://discuss.elastic.co/u/malaranjo)
#### Post date: [September 18, 2025, 4:40pm UTC](https://discuss.elastic.co/t/interleaving-search-results-in-elasticsearch/382063/1 "2025-09-18T16:40:50Z")

</div>

Hi Elasticsearch community,

I’m implementing a search feature where items belong to groups, and some groups are marked as **premium**. I want search results to:

1. Show **all items from premium groups first** , then non-premium items.

2. **Interleave items across premium groups** in a round-robin fashion, e.g.:

```auto
group1 → item1
group2 → item1
group3 → item1
group1 → item2
group2 → item2
...

```

- Filters may be applied (e.g., ranges, categories).

- Supports pagination (size=24, for example)

I’ve explored:

- Pre-computing a rank within each group — breaks when filters are applied and remove items.

- `terms` agg by group and then a `top_hits` for each group - not exactly what i want too and does not support pagination. Also, i don’t have a fixed amount of premium groups or items.

Is there any native or recommended way to achieve this kind of weighted round-robin or interleaving within Elasticsearch’s query or sorting capabilities?

If not, are there best practices or patterns to implement this efficiently, maybe combining ES with application-side logic? However, the application-side logic can not have an impact in application performance.

Thanks in advance!
