# How can I merge the results of two aggregations?

**URL:** https://discuss.elastic.co/t/how-can-i-merge-the-results-of-two-aggregations/14927
**Category:** Elasticsearch
**Created:** [December 18, 2013, 8:58am UTC](https://discuss.elastic.co/t/how-can-i-merge-the-results-of-two-aggregations/14927 "2013-12-18T08:58:07Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Tim\_S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tim_s/32/958_2.png) [@Tim\_S](https://discuss.elastic.co/u/Tim_S)
#### Post date: [December 18, 2013, 8:58am UTC](https://discuss.elastic.co/t/how-can-i-merge-the-results-of-two-aggregations/14927/1 "2013-12-18T08:58:07Z")

</div>

In the example below, I ask elasticsearch for two aggregations (I've  
simplified it, it's actually got some nested aggregations in there).

{  
"aggregations": {  
"agg1": {  
"terms": {  
"field": "forname"  
}  
},  
"agg2": {  
"terms": {  
"field": "surname"  
}  
}  
}  
}

What I get back is two sets of results, i.e.

{  
"aggregations" : {  
"agg1" : {  
"buckets" : [ {  
"key" : "john",  
"doc\_count" : 1  
}, {  
"key" : "bob",  
"doc\_count" : 4  
} ]  
},  
"agg2" : {  
"buckets" : [ {  
"key" : "smith",  
"doc\_count" : 3  
}, {  
"key" : "jones",  
"doc\_count" : 2  
} ]  
}  
}  
}

What I'd like to get back is one set of results. I.e. a list of terms  
appearing in either of the fields, with the counts summed across both, e.g.

{  
"aggregations" : {  
"agg1 OR agg2" : {  
"buckets" : [ {  
"key" : "john",  
"doc\_count" : 1  
}, {  
"key" : "bob",  
"doc\_count" : 4  
}, {  
"key" : "smith",  
"doc\_count" : 3  
}, {  
"key" : "jones",  
"doc\_count" : 2  
} ]  
}  
}  
}

Is there any way of doing this? I could request them and merge them in my  
own code, but if there's a built in way then I'd rather use that.

Thanks,

Tim.

--  
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/731d5734-25ff-4d29-ad11-3a9f6a382244%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/731d5734-25ff-4d29-ad11-3a9f6a382244%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![zkidkid](https://avatars.discourse-cdn.com/v4/letter/z/fbc32d/32.png) [@zkidkid](https://discuss.elastic.co/u/zkidkid)
#### Post date: [December 18, 2013, 4:40pm UTC](https://discuss.elastic.co/t/how-can-i-merge-the-results-of-two-aggregations/14927/2 "2013-12-18T16:40:37Z")

</div>

You could use bool query and let Elasticsearch do the rest.

> **[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 Wednesday, December 18, 2013 3:58:07 PM UTC+7, Tim S wrote:

> In the example below, I ask elasticsearch for two aggregations (I've  
> simplified it, it's actually got some nested aggregations in there).
> 
> {  
> "aggregations": {  
> "agg1": {  
> "terms": {  
> "field": "forname"  
> }  
> },  
> "agg2": {  
> "terms": {  
> "field": "surname"  
> }  
> }  
> }  
> }
> 
> What I get back is two sets of results, i.e.
> 
> {  
> "aggregations" : {  
> "agg1" : {  
> "buckets" : [ {  
> "key" : "john",  
> "doc\_count" : 1  
> }, {  
> "key" : "bob",  
> "doc\_count" : 4  
> } ]  
> },  
> "agg2" : {  
> "buckets" : [ {  
> "key" : "smith",  
> "doc\_count" : 3  
> }, {  
> "key" : "jones",  
> "doc\_count" : 2  
> } ]  
> }  
> }  
> }
> 
> What I'd like to get back is one set of results. I.e. a list of terms  
> appearing in either of the fields, with the counts summed across both, e.g.
> 
> {  
> "aggregations" : {  
> "agg1 OR agg2" : {  
> "buckets" : [ {  
> "key" : "john",  
> "doc\_count" : 1  
> }, {  
> "key" : "bob",  
> "doc\_count" : 4  
> }, {  
> "key" : "smith",  
> "doc\_count" : 3  
> }, {  
> "key" : "jones",  
> "doc\_count" : 2  
> } ]  
> }  
> }  
> }
> 
> Is there any way of doing this? I could request them and merge them in my  
> own code, but if there's a built in way then I'd rather use that.
> 
> Thanks,
> 
> Tim.

--  
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/8e57316e-2c43-40cc-913e-6f9579fc0410%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8e57316e-2c43-40cc-913e-6f9579fc0410%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Tim\_S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tim_s/32/958_2.png) [@Tim\_S](https://discuss.elastic.co/u/Tim_S)
#### Post date: [December 19, 2013, 10:29am UTC](https://discuss.elastic.co/t/how-can-i-merge-the-results-of-two-aggregations/14927/3 "2013-12-19T10:29:06Z")

</div>

How can I use bool query on the result of an aggregation? I want both  
aggregations to independently facet on the whole index, then merge the  
results. I can see how I would use a bool query to limit the set of docs  
I'm aggregating on, but I can't see how I would use it to merge the results  
of two aggregations?

Thanks,

Tim.

On Wednesday, December 18, 2013 4:40:37 PM UTC, kidkid wrote:

> You could use bool query and let Elasticsearch do the rest.
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html)
> 
> On Wednesday, December 18, 2013 3:58:07 PM UTC+7, Tim S wrote:
> 
> > In the example below, I ask elasticsearch for two aggregations (I've  
> > simplified it, it's actually got some nested aggregations in there).
> > 
> > {  
> > "aggregations": {  
> > "agg1": {  
> > "terms": {  
> > "field": "forname"  
> > }  
> > },  
> > "agg2": {  
> > "terms": {  
> > "field": "surname"  
> > }  
> > }  
> > }  
> > }
> > 
> > What I get back is two sets of results, i.e.
> > 
> > {  
> > "aggregations" : {  
> > "agg1" : {  
> > "buckets" : [ {  
> > "key" : "john",  
> > "doc\_count" : 1  
> > }, {  
> > "key" : "bob",  
> > "doc\_count" : 4  
> > } ]  
> > },  
> > "agg2" : {  
> > "buckets" : [ {  
> > "key" : "smith",  
> > "doc\_count" : 3  
> > }, {  
> > "key" : "jones",  
> > "doc\_count" : 2  
> > } ]  
> > }  
> > }  
> > }
> > 
> > What I'd like to get back is one set of results. I.e. a list of terms  
> > appearing in either of the fields, with the counts summed across both, e.g.
> > 
> > {  
> > "aggregations" : {  
> > "agg1 OR agg2" : {  
> > "buckets" : [ {  
> > "key" : "john",  
> > "doc\_count" : 1  
> > }, {  
> > "key" : "bob",  
> > "doc\_count" : 4  
> > }, {  
> > "key" : "smith",  
> > "doc\_count" : 3  
> > }, {  
> > "key" : "jones",  
> > "doc\_count" : 2  
> > } ]  
> > }  
> > }  
> > }
> > 
> > Is there any way of doing this? I could request them and merge them in my  
> > own code, but if there's a built in way then I'd rather use that.
> > 
> > Thanks,
> > 
> > Tim.

--  
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/b9c82b3b-c8a3-4783-96d8-b4d07809189f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b9c82b3b-c8a3-4783-96d8-b4d07809189f%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![zkidkid](https://avatars.discourse-cdn.com/v4/letter/z/fbc32d/32.png) [@zkidkid](https://discuss.elastic.co/u/zkidkid)
#### Post date: [December 20, 2013, 2:54am UTC](https://discuss.elastic.co/t/how-can-i-merge-the-results-of-two-aggregations/14927/4 "2013-12-20T02:54:14Z")

</div>

Hi sorry, it would be my mistake:

Could you take a look at  
OrFilter: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-or-filter.html)

In your case I think you could use match all query & use OrFilter & let ES  
merge the result.

On Thursday, December 19, 2013 2:29:06 AM UTC-8, Tim S wrote:

> How can I use bool query on the result of an aggregation? I want both  
> aggregations to independently facet on the whole index, then merge the  
> results. I can see how I would use a bool query to limit the set of docs  
> I'm aggregating on, but I can't see how I would use it to merge the results  
> of two aggregations?
> 
> Thanks,
> 
> Tim.
> 
> On Wednesday, December 18, 2013 4:40:37 PM UTC, kidkid wrote:
> 
> > You could use bool query and let Elasticsearch do the rest.
> > 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html)
> > 
> > On Wednesday, December 18, 2013 3:58:07 PM UTC+7, Tim S wrote:
> > 
> > > In the example below, I ask elasticsearch for two aggregations (I've  
> > > simplified it, it's actually got some nested aggregations in there).
> > > 
> > > {  
> > > "aggregations": {  
> > > "agg1": {  
> > > "terms": {  
> > > "field": "forname"  
> > > }  
> > > },  
> > > "agg2": {  
> > > "terms": {  
> > > "field": "surname"  
> > > }  
> > > }  
> > > }  
> > > }
> > > 
> > > What I get back is two sets of results, i.e.
> > > 
> > > {  
> > > "aggregations" : {  
> > > "agg1" : {  
> > > "buckets" : [ {  
> > > "key" : "john",  
> > > "doc\_count" : 1  
> > > }, {  
> > > "key" : "bob",  
> > > "doc\_count" : 4  
> > > } ]  
> > > },  
> > > "agg2" : {  
> > > "buckets" : [ {  
> > > "key" : "smith",  
> > > "doc\_count" : 3  
> > > }, {  
> > > "key" : "jones",  
> > > "doc\_count" : 2  
> > > } ]  
> > > }  
> > > }  
> > > }
> > > 
> > > What I'd like to get back is one set of results. I.e. a list of terms  
> > > appearing in either of the fields, with the counts summed across both, e.g.
> > > 
> > > {  
> > > "aggregations" : {  
> > > "agg1 OR agg2" : {  
> > > "buckets" : [ {  
> > > "key" : "john",  
> > > "doc\_count" : 1  
> > > }, {  
> > > "key" : "bob",  
> > > "doc\_count" : 4  
> > > }, {  
> > > "key" : "smith",  
> > > "doc\_count" : 3  
> > > }, {  
> > > "key" : "jones",  
> > > "doc\_count" : 2  
> > > } ]  
> > > }  
> > > }  
> > > }
> > > 
> > > Is there any way of doing this? I could request them and merge them in  
> > > my own code, but if there's a built in way then I'd rather use that.
> > > 
> > > Thanks,
> > > 
> > > Tim.

--  
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/0c8d436c-c244-4cac-8ae1-efa75583667a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0c8d436c-c244-4cac-8ae1-efa75583667a%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Tim\_S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tim_s/32/958_2.png) [@Tim\_S](https://discuss.elastic.co/u/Tim_S)
#### Post date: [December 20, 2013, 9:53am UTC](https://discuss.elastic.co/t/how-can-i-merge-the-results-of-two-aggregations/14927/5 "2013-12-20T09:53:07Z")

</div>

Sorry, maybe I'm missing something. Afaics the OR filter would operate on  
filters or queries, not on aggregations. Can you give me an example of how  
I'd use this to merge the result of the two aggregations?

Thanks.

On Friday, December 20, 2013 2:54:14 AM UTC, kidkid wrote:

> Hi sorry, it would be my mistake:
> 
> Could you take a look at OrFilter:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-or-filter.html)
> 
> In your case I think you could use match all query & use OrFilter & let ES  
> merge the result.
> 
> On Thursday, December 19, 2013 2:29:06 AM UTC-8, Tim S wrote:
> 
> > How can I use bool query on the result of an aggregation? I want both  
> > aggregations to independently facet on the whole index, then merge the  
> > results. I can see how I would use a bool query to limit the set of docs  
> > I'm aggregating on, but I can't see how I would use it to merge the results  
> > of two aggregations?
> > 
> > Thanks,
> > 
> > Tim.
> > 
> > On Wednesday, December 18, 2013 4:40:37 PM UTC, kidkid wrote:
> > 
> > > You could use bool query and let Elasticsearch do the rest.
> > > 
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html)
> > > 
> > > On Wednesday, December 18, 2013 3:58:07 PM UTC+7, Tim S wrote:
> > > 
> > > > In the example below, I ask elasticsearch for two aggregations (I've  
> > > > simplified it, it's actually got some nested aggregations in there).
> > > > 
> > > > {  
> > > > "aggregations": {  
> > > > "agg1": {  
> > > > "terms": {  
> > > > "field": "forname"  
> > > > }  
> > > > },  
> > > > "agg2": {  
> > > > "terms": {  
> > > > "field": "surname"  
> > > > }  
> > > > }  
> > > > }  
> > > > }
> > > > 
> > > > What I get back is two sets of results, i.e.
> > > > 
> > > > {  
> > > > "aggregations" : {  
> > > > "agg1" : {  
> > > > "buckets" : [ {  
> > > > "key" : "john",  
> > > > "doc\_count" : 1  
> > > > }, {  
> > > > "key" : "bob",  
> > > > "doc\_count" : 4  
> > > > } ]  
> > > > },  
> > > > "agg2" : {  
> > > > "buckets" : [ {  
> > > > "key" : "smith",  
> > > > "doc\_count" : 3  
> > > > }, {  
> > > > "key" : "jones",  
> > > > "doc\_count" : 2  
> > > > } ]  
> > > > }  
> > > > }  
> > > > }
> > > > 
> > > > What I'd like to get back is one set of results. I.e. a list of terms  
> > > > appearing in either of the fields, with the counts summed across both, e.g.
> > > > 
> > > > {  
> > > > "aggregations" : {  
> > > > "agg1 OR agg2" : {  
> > > > "buckets" : [ {  
> > > > "key" : "john",  
> > > > "doc\_count" : 1  
> > > > }, {  
> > > > "key" : "bob",  
> > > > "doc\_count" : 4  
> > > > }, {  
> > > > "key" : "smith",  
> > > > "doc\_count" : 3  
> > > > }, {  
> > > > "key" : "jones",  
> > > > "doc\_count" : 2  
> > > > } ]  
> > > > }  
> > > > }  
> > > > }
> > > > 
> > > > Is there any way of doing this? I could request them and merge them in  
> > > > my own code, but if there's a built in way then I'd rather use that.
> > > > 
> > > > Thanks,
> > > > 
> > > > Tim.

--  
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/067e2d3e-2d7f-46e9-9ce6-0384a9a89b43%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/067e2d3e-2d7f-46e9-9ce6-0384a9a89b43%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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: [December 24, 2013, 3:42pm UTC](https://discuss.elastic.co/t/how-can-i-merge-the-results-of-two-aggregations/14927/6 "2013-12-24T15:42:38Z")

</div>

You can use scripts to run aggregations on the union of two fields. Here is  
an example:

GET /test/\_search  
{  
"aggregations": {  
"name" : {  
"terms" : {  
"script": "\_doc['firstname'].values +  
\_doc['lastname'].values"  
}  
}  
}  
}

Another alternative would be to index both first names and last names in a  
single 'name' field and to run the aggregation on this field at search  
time. Although this would require more disk space, this would also be  
faster.

On Fri, Dec 20, 2013 at 10:53 AM, Tim S [timstibbs@gmail.com](mailto:timstibbs@gmail.com) wrote:

> Sorry, maybe I'm missing something. Afaics the OR filter would operate on  
> filters or queries, not on aggregations. Can you give me an example of how  
> I'd use this to merge the result of the two aggregations?
> 
> Thanks.
> 
> On Friday, December 20, 2013 2:54:14 AM UTC, kidkid wrote:
> 
> > Hi sorry, it would be my mistake:
> > 
> > Could you take a look at OrFilter: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/)  
> > elasticsearch/reference/current/query-dsl-or-filter.html
> > 
> > In your case I think you could use match all query & use OrFilter & let  
> > ES merge the result.
> > 
> > On Thursday, December 19, 2013 2:29:06 AM UTC-8, Tim S wrote:
> > 
> > > How can I use bool query on the result of an aggregation? I want both  
> > > aggregations to independently facet on the whole index, then merge the  
> > > results. I can see how I would use a bool query to limit the set of docs  
> > > I'm aggregating on, but I can't see how I would use it to merge the results  
> > > of two aggregations?
> > > 
> > > Thanks,
> > > 
> > > Tim.
> > > 
> > > On Wednesday, December 18, 2013 4:40:37 PM UTC, kidkid wrote:
> > > 
> > > > You could use bool query and let Elasticsearch do the rest.
> > > > 
> > > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/)  
> > > > reference/current/query-dsl-bool-query.html
> > > > 
> > > > On Wednesday, December 18, 2013 3:58:07 PM UTC+7, Tim S wrote:
> > > > 
> > > > > In the example below, I ask elasticsearch for two aggregations (I've  
> > > > > simplified it, it's actually got some nested aggregations in there).
> > > > > 
> > > > > {  
> > > > > "aggregations": {  
> > > > > "agg1": {  
> > > > > "terms": {  
> > > > > "field": "forname"  
> > > > > }  
> > > > > },  
> > > > > "agg2": {  
> > > > > "terms": {  
> > > > > "field": "surname"  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > }
> > > > > 
> > > > > What I get back is two sets of results, i.e.
> > > > > 
> > > > > {  
> > > > > "aggregations" : {  
> > > > > "agg1" : {  
> > > > > "buckets" : [ {  
> > > > > "key" : "john",  
> > > > > "doc\_count" : 1  
> > > > > }, {  
> > > > > "key" : "bob",  
> > > > > "doc\_count" : 4  
> > > > > } ]  
> > > > > },  
> > > > > "agg2" : {  
> > > > > "buckets" : [ {  
> > > > > "key" : "smith",  
> > > > > "doc\_count" : 3  
> > > > > }, {  
> > > > > "key" : "jones",  
> > > > > "doc\_count" : 2  
> > > > > } ]  
> > > > > }  
> > > > > }  
> > > > > }
> > > > > 
> > > > > What I'd like to get back is one set of results. I.e. a list of terms  
> > > > > appearing in either of the fields, with the counts summed across both, e.g.
> > > > > 
> > > > > {  
> > > > > "aggregations" : {  
> > > > > "agg1 OR agg2" : {  
> > > > > "buckets" : [ {  
> > > > > "key" : "john",  
> > > > > "doc\_count" : 1  
> > > > > }, {  
> > > > > "key" : "bob",  
> > > > > "doc\_count" : 4  
> > > > > }, {  
> > > > > "key" : "smith",  
> > > > > "doc\_count" : 3  
> > > > > }, {  
> > > > > "key" : "jones",  
> > > > > "doc\_count" : 2  
> > > > > } ]  
> > > > > }  
> > > > > }  
> > > > > }
> > > > > 
> > > > > Is there any way of doing this? I could request them and merge them in  
> > > > > my own code, but if there's a built in way then I'd rather use that.
> > > > > 
> > > > > Thanks,
> > > > > 
> > > > > Tim.
> > > > 
> > > > --  
> > > > 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/067e2d3e-2d7f-46e9-9ce6-0384a9a89b43%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/067e2d3e-2d7f-46e9-9ce6-0384a9a89b43%40googlegroups.com)  
> > > > .
> 
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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/CAL6Z4j4VLK-NQbREqtTwVeDC%3DrTgTcWfyxjeWmF\_uL%3DeJsus6A%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j4VLK-NQbREqtTwVeDC%3DrTgTcWfyxjeWmF_uL%3DeJsus6A%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![roytmana](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/roytmana/32/44855_2.png) [@roytmana](https://discuss.elastic.co/u/roytmana)
#### Post date: [December 26, 2013, 5:00am UTC](https://discuss.elastic.co/t/how-can-i-merge-the-results-of-two-aggregations/14927/7 "2013-12-26T05:00:52Z")

</div>

I have not looked at aggs but term facet can run against multiple fields.

--  
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/e37b88d6-9a48-4d5f-9787-2ad615eb574d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e37b88d6-9a48-4d5f-9787-2ad615eb574d%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:59am UTC](https://discuss.elastic.co/t/how-can-i-merge-the-results-of-two-aggregations/14927/8 "2017-07-06T01:59:24Z")

</div>


