# Terms aggregation for multiple fields

**URL:** <https://discuss.elastic.co/t/terms-aggregation-for-multiple-fields/18238>\
**Category:** Elasticsearch\
**Created:** [June 20, 2014, 7:41pm UTC](https://discuss.elastic.co/t/terms-aggregation-for-multiple-fields/18238 "2014-06-20T19:41:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Madhavan\_Ramachandra](https://avatars.discourse-cdn.com/v4/letter/m/a88e57/32.png) [@Madhavan\_Ramachandra](https://discuss.elastic.co/u/Madhavan_Ramachandra)\
**Post date:** [June 20, 2014, 7:41pm UTC](https://discuss.elastic.co/t/terms-aggregation-for-multiple-fields/18238/1 "2014-06-20T19:41:27Z")

</div>

Hi Team,  
I am new to elasticsearch and learning about the searchapi/queryapi in  
elasticsearch.

I have a requirement to fetch the data from ES. My data is as below assume  
in a table format

Prop-Name Type Use  
Place1 Sale Office  
Place2 Lease Office  
Place3 SubLease Office  
Place4 Sale Industry  
....

So in type i have Sale, Lease, sublease as distinct values for the  
property. Similarly for use i have 7 distinct types.

I have loaded the data as into ES. My need.. at the pageload.. i need to  
showe the count of each type and each use.

Upon selection of type, i need to filter the "use" and viceversa.

Assume if we have total 30 places for Type Sale ..then the Use might have  
Office15 and Industry 15..

When i select Office 15.. I need to find in the document how many types of  
each belong to Office.

1. All the time, I have to populate the distinct values (3 types and 7 use  
) and their counts based on the selection of each
2. How to do aggregation if the Use field having values as "Multi-family"  
and want to show as one aggregated value? Current query bring me as two  
results for this value.

Regards  
Madhavan.TR

--  
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/8f803b70-d8ff-4dbd-a4bb-0f71ecaec679%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8f803b70-d8ff-4dbd-a4bb-0f71ecaec679%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:20am UTC](https://discuss.elastic.co/t/terms-aggregation-for-multiple-fields/18238/2 "2017-07-06T01:20:53Z")

</div>


