# Optimize sub-aggregations when index is routed by primary bucket aggregation

**URL:** <https://discuss.elastic.co/t/optimize-sub-aggregations-when-index-is-routed-by-primary-bucket-aggregation/21556>\
**Category:** Elasticsearch\
**Created:** [January 9, 2015, 12:49pm UTC](https://discuss.elastic.co/t/optimize-sub-aggregations-when-index-is-routed-by-primary-bucket-aggregation/21556 "2015-01-09T12:49:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chuck](https://avatars.discourse-cdn.com/v4/letter/c/8e7dd6/32.png) [@chuck](https://discuss.elastic.co/u/chuck)\
**Post date:** [January 9, 2015, 12:49pm UTC](https://discuss.elastic.co/t/optimize-sub-aggregations-when-index-is-routed-by-primary-bucket-aggregation/21556/1 "2015-01-09T12:49:12Z")

</div>

I'm not sure if anything like this is in place already, but when documents  
are routed by a given field that is later used as a primary bucket  
aggregation, all data for sub-aggregations will be shard local. It could  
be beneficial to take advantage of that locality. Has anyone explored or  
considered this?

--  
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/565a3aca-4c49-4b78-a4d3-d68e84caa13f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/565a3aca-4c49-4b78-a4d3-d68e84caa13f%40googlegroups.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, 12:39am UTC](https://discuss.elastic.co/t/optimize-sub-aggregations-when-index-is-routed-by-primary-bucket-aggregation/21556/2 "2017-07-06T00:39:52Z")

</div>

Closed on July 6, 2017, 12:39am UTC


