# Aggregation equivalent of Facet "global" : true?

**URL:** <https://discuss.elastic.co/t/aggregation-equivalent-of-facet-global-true/18040>\
**Category:** Elasticsearch\
**Created:** [June 11, 2014, 10:02am UTC](https://discuss.elastic.co/t/aggregation-equivalent-of-facet-global-true/18040 "2014-06-11T10:02:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mooky](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@mooky](https://discuss.elastic.co/u/mooky)\
**Post date:** [June 11, 2014, 10:02am UTC](https://discuss.elastic.co/t/aggregation-equivalent-of-facet-global-true/18040/1 "2014-06-11T10:02:21Z")

</div>

Is there a way of specifying the scope of an aggregation (if there is I  
cant seem to find it)?

I want to achieve the equivalent of a Facet "global" : true.

Do I need to use facets instead of aggregations in this case?

I am just doing term aggregations - to give the user a dropdown list to  
filter by, say, commodity - and provide choices like:  
Aluminium (0)  
Copper (110)  
Gold (6)  
Lead (243)  
Zinc (0)

I want to do a global aggregation to get all the possible terms (ie all  
possible filter values).  
I want to do a contextual (based on current user query) term aggregation to  
get the counts.

How do I do this with Aggregations?

Thanks

--  
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/2ea2b66e-5274-4d04-a4b4-dabef399db13%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2ea2b66e-5274-4d04-a4b4-dabef399db13%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [June 11, 2014, 10:23am UTC](https://discuss.elastic.co/t/aggregation-equivalent-of-facet-global-true/18040/2 "2014-06-11T10:23:52Z")

</div>

You can do this by running a `global` aggregation:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

On Wed, Jun 11, 2014 at 12:02 PM, mooky [nick.minutello@gmail.com](mailto:nick.minutello@gmail.com) wrote:

> Is there a way of specifying the scope of an aggregation (if there is I  
> cant seem to find it)?
> 
> I want to achieve the equivalent of a Facet "global" : true.
> 
> Do I need to use facets instead of aggregations in this case?
> 
> I am just doing term aggregations - to give the user a dropdown list to  
> filter by, say, commodity - and provide choices like:  
> Aluminium (0)  
> Copper (110)  
> Gold (6)  
> Lead (243)  
> Zinc (0)
> 
> I want to do a global aggregation to get all the possible terms (ie all  
> possible filter values).  
> I want to do a contextual (based on current user query) term aggregation  
> to get the counts.
> 
> How do I do this with Aggregations?
> 
> Thanks
> 
> --  
> 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/2ea2b66e-5274-4d04-a4b4-dabef399db13%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2ea2b66e-5274-4d04-a4b4-dabef399db13%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/2ea2b66e-5274-4d04-a4b4-dabef399db13%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/2ea2b66e-5274-4d04-a4b4-dabef399db13%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
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/CAL6Z4j7oewksDpV0Nkqoczw5Wkjq4uO2m%2B4eDZcshSu5Yb5HyQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7oewksDpV0Nkqoczw5Wkjq4uO2m%2B4eDZcshSu5Yb5HyQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![mooky](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@mooky](https://discuss.elastic.co/u/mooky)\
**Post date:** [June 11, 2014, 10:36am UTC](https://discuss.elastic.co/t/aggregation-equivalent-of-facet-global-true/18040/3 "2014-06-11T10:36:13Z")

</div>

Aha. I missed that. Many thanks.

On Wednesday, 11 June 2014 11:23:57 UTC+1, Adrien Grand wrote:

> You can do this by running a `global` aggregation:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-global-aggregation.html)
> 
> On Wed, Jun 11, 2014 at 12:02 PM, mooky \<[nick.mi...@gmail.com](mailto:nick.mi...@gmail.com)  
> \<javascript:\>\> wrote:
> 
> > Is there a way of specifying the scope of an aggregation (if there is I  
> > cant seem to find it)?
> > 
> > I want to achieve the equivalent of a Facet "global" : true.
> > 
> > Do I need to use facets instead of aggregations in this case?
> > 
> > I am just doing term aggregations - to give the user a dropdown list to  
> > filter by, say, commodity - and provide choices like:  
> > Aluminium (0)  
> > Copper (110)  
> > Gold (6)  
> > Lead (243)  
> > Zinc (0)
> > 
> > I want to do a global aggregation to get all the possible terms (ie all  
> > possible filter values).  
> > I want to do a contextual (based on current user query) term aggregation  
> > to get the counts.
> > 
> > How do I do this with Aggregations?
> > 
> > Thanks
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/2ea2b66e-5274-4d04-a4b4-dabef399db13%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2ea2b66e-5274-4d04-a4b4-dabef399db13%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/2ea2b66e-5274-4d04-a4b4-dabef399db13%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/2ea2b66e-5274-4d04-a4b4-dabef399db13%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> Adrien Grand

--  
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/86b96aae-6a71-4e47-a605-3db55a120905%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/86b96aae-6a71-4e47-a605-3db55a120905%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, 1:23am UTC](https://discuss.elastic.co/t/aggregation-equivalent-of-facet-global-true/18040/4 "2017-07-06T01:23:20Z")

</div>


