# Multi index aggregations

**URL:** <https://discuss.elastic.co/t/multi-index-aggregations/302012>\
**Category:** Elasticsearch\
**Created:** [April 9, 2022, 4:41am UTC](https://discuss.elastic.co/t/multi-index-aggregations/302012 "2022-04-09T04:41:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kasvith](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kasvith/32/104185_2.png) [@kasvith](https://discuss.elastic.co/u/kasvith)\
**Post date:** [April 9, 2022, 4:41am UTC](https://discuss.elastic.co/t/multi-index-aggregations/302012/1 "2022-04-09T04:41:07Z")

</div>

Hi all, I've a scenario like this

Im maintaining an index for a list that holds the basic fields like `title`  
I also maintain two separate indexes called `idx-1` and `idx-2` which also have `listId` as a field.  
When Im adding an entry, I decide the index based on user input and store data there.

Now, when i retrieve multiple lists from the `list` index, i want to count all the documents from `idx-1` and `idx-2` for each list (more like a count subquery in SQL)

Can I do this with Elastic? this aggregation involves connecting multiple indexes to get the result

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [April 9, 2022, 1:20pm UTC](https://discuss.elastic.co/t/multi-index-aggregations/302012/2 "2022-04-09T13:20:32Z")

</div>

I don't know if this is exactly your problem but it's the same context.

> [@Aggregation across multiple indices](https://discuss.elastic.co/t/aggregation-across-multiple-indices/271350):
>
> I have 2 indices and they store data of the same mappings on different dates - t1 and t2. I have a multi term aggregation below which works on a single index. How can I get elasticsearch to return the same aggregation across t1 and t2 as well as do some comparison like t1.total-price - t2.total-price? PUT t1/\_mappings/ { "properties": { "account": { "type": "text", "fields": { "keyword": { "type": "keyword", "ign…

---

<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:** [May 7, 2022, 1:21pm UTC](https://discuss.elastic.co/t/multi-index-aggregations/302012/3 "2022-05-07T13:21:26Z")

</div>

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