# Java Client Aggregation question

**URL:** <https://discuss.elastic.co/t/java-client-aggregation-question/22289>\
**Category:** Elasticsearch\
**Created:** [February 20, 2015, 11:32am UTC](https://discuss.elastic.co/t/java-client-aggregation-question/22289 "2015-02-20T11:32:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Williams](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matt_williams/32/896_2.png) [@Matt\_Williams](https://discuss.elastic.co/u/Matt_Williams)\
**Post date:** [February 20, 2015, 11:32am UTC](https://discuss.elastic.co/t/java-client-aggregation-question/22289/1 "2015-02-20T11:32:39Z")

</div>

Hi all,

I am currently indexing tags (industries) for an entity with a data  
structure like this:

industry: ["Consulting & Recruitment","Professional Services","Education & Training"]

I am applying a termsAggregation to the query as:

AggregationBuilders.terms("industry").field("industry");

What I expect to come out:

Key: "Consulting & Recruitment"

docCount: 100

What I actually get:

Key: "Consulting"

docCount: 100

Key: "Recruitment"

docCount: 100.

Is there a way to correct this?

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/e86c02ab-9699-41ea-88b3-871ed761dad6%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e86c02ab-9699-41ea-88b3-871ed761dad6%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 20, 2015, 12:38pm UTC](https://discuss.elastic.co/t/java-client-aggregation-question/22289/2 "2015-02-20T12:38:16Z")

</div>

Yes. Change your mapping and define the field as not\_analyzed.

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr) | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)

> Le 20 févr. 2015 à 12:32, Matt Williams [wattmilliams@gmail.com](mailto:wattmilliams@gmail.com) a écrit :
> 
> Hi all,
> 
> I am currently indexing tags (industries) for an entity with a data structure like this:
> 
> industry: ["Consulting & Recruitment","Professional Services","Education & Training"]  
> I am applying a termsAggregation to the query as:
> 
> AggregationBuilders.terms("industry").field("industry");  
> What I expect to come out:
> 
> Key: "Consulting & Recruitment"
> 
> docCount: 100
> 
> What I actually get:
> 
> Key: "Consulting"
> 
> docCount: 100
> 
> Key: "Recruitment"
> 
> docCount: 100.
> 
> Is there a way to correct this?
> 
> 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) [mailto:elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e86c02ab-9699-41ea-88b3-871ed761dad6%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e86c02ab-9699-41ea-88b3-871ed761dad6%40googlegroups.com) [https://groups.google.com/d/msgid/elasticsearch/e86c02ab-9699-41ea-88b3-871ed761dad6%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/e86c02ab-9699-41ea-88b3-871ed761dad6%40googlegroups.com?utm_medium=email&utm_source=footer).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout) [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/6A33DAF3-C491-4EBA-8C1D-77F83C52160F%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/6A33DAF3-C491-4EBA-8C1D-77F83C52160F%40pilato.fr).  
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:31am UTC](https://discuss.elastic.co/t/java-client-aggregation-question/22289/3 "2017-07-06T00:31:15Z")

</div>


