# Aggregation across indices

**URL:** <https://discuss.elastic.co/t/aggregation-across-indices/19461>\
**Category:** Elasticsearch\
**Created:** [August 26, 2014, 12:34pm UTC](https://discuss.elastic.co/t/aggregation-across-indices/19461 "2014-08-26T12:34:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ElasticSearch\_Users\_](https://avatars.discourse-cdn.com/v4/letter/e/b4bc9f/32.png) [@ElasticSearch\_Users\_](https://discuss.elastic.co/u/ElasticSearch_Users_)\
**Post date:** [August 26, 2014, 12:34pm UTC](https://discuss.elastic.co/t/aggregation-across-indices/19461/1 "2014-08-26T12:34:25Z")

</div>

Hi,

If I have two indices each having part of the record and joined using some  
common identifier, can I issue a query across both indices and have  
aggregations apply taking into consideration both indices?

Example:  
Index 1: Type 1:  
ID: String  
Field1: String  
Field2: String

Index 2: Type 2:  
ID: String (From above. I can keep this same to behave like a foreign key.)  
Field3: String  
Field4: String

Can I effect a join across both indices and aggregate on Field4 for example?

Please let me know. Thanks,  
Sandeep

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2b839a9a-b109-4948-8d8b-58107f77572e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2b839a9a-b109-4948-8d8b-58107f77572e%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineeth_mohan_2/32/747_2.png) [@vineeth\_mohan\_2](https://discuss.elastic.co/u/vineeth_mohan_2)\
**Post date:** [August 26, 2014, 12:46pm UTC](https://discuss.elastic.co/t/aggregation-across-indices/19461/2 "2014-08-26T12:46:22Z")

</div>

Hello Sandeep ,

What you are intending is not possible.  
But then Elasticsearch do have some good relational operations which needs  
to be defined before indexing.  
If you can elaborate your use case , we can help on this.

Thanks  
Vineeth

On Tue, Aug 26, 2014 at 6:04 PM, 'Sandeep Ramesh Khanzode' via  
elasticsearch [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com) wrote:

> Hi,
> 
> If I have two indices each having part of the record and joined using some  
> common identifier, can I issue a query across both indices and have  
> aggregations apply taking into consideration both indices?
> 
> Example:  
> Index 1: Type 1:  
> ID: String  
> Field1: String  
> Field2: String
> 
> Index 2: Type 2:  
> ID: String (From above. I can keep this same to behave like a foreign key.)  
> Field3: String  
> Field4: String
> 
> Can I effect a join across both indices and aggregate on Field4 for  
> example?
> 
> Please let me know. Thanks,  
> Sandeep
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/2b839a9a-b109-4948-8d8b-58107f77572e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2b839a9a-b109-4948-8d8b-58107f77572e%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/2b839a9a-b109-4948-8d8b-58107f77572e%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/2b839a9a-b109-4948-8d8b-58107f77572e%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGdPd5%3D93B%2Bk1QCKQHg\_n%3D%3Da9Yih9Lyi1k4Gt\_LZ7kywnBiroQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5%3D93B%2Bk1QCKQHg_n%3D%3Da9Yih9Lyi1k4Gt_LZ7kywnBiroQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 1:06am UTC](https://discuss.elastic.co/t/aggregation-across-indices/19461/3 "2017-07-06T01:06:27Z")

</div>


