# Aggregations and special characters

**URL:** <https://discuss.elastic.co/t/aggregations-and-special-characters/18559>\
**Category:** Elasticsearch\
**Created:** [July 9, 2014, 5:08pm UTC](https://discuss.elastic.co/t/aggregations-and-special-characters/18559 "2014-07-09T17:08:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lucas\_Rutledge](https://avatars.discourse-cdn.com/v4/letter/l/9fc29f/32.png) [@Lucas\_Rutledge](https://discuss.elastic.co/u/Lucas_Rutledge)\
**Post date:** [July 9, 2014, 5:08pm UTC](https://discuss.elastic.co/t/aggregations-and-special-characters/18559/1 "2014-07-09T17:08:16Z")

</div>

I am performing an terms aggregation on a query to return the unique values  
of a field, in this case the field being emails in the format  
[example@gmail.com](mailto:example@gmail.com) or [example@aaa.example.com](mailto:example@aaa.example.com).

"aggregations": {  
"users\_overall": {  
"terms": {  
"field": "email"  
}  
}  
}  
Instead of receiving back the full unique emails that I need I get results  
such as these:

- {
- 
  - key: [gmail.com](http://gmail.com)
  - doc\_count: 121864  
}

- {
  - key: [yahoo.com](http://yahoo.com)
  - doc\_count: 68648  
}

- {
  - key: [roadrunner.com](http://roadrunner.com)
  - doc\_count: 58194  
}

- {
  - key: [optimum.net](http://optimum.net)
  - doc\_count: 35162  
}

- {
  - key: [hotmail.com](http://hotmail.com)
  - doc\_count: 31407  
}

- {
  - key: [nyc.rr.com](http://nyc.rr.com)
  - doc\_count: 24010  
}

- {
  - key: [aol.com](http://aol.com)
  - doc\_count: 22502  
}

- 
- I've run into this problem with other fields that have values with  
special characters in them as well, is there any way to perform an  
aggregation like this that can ignore the special characters and return the  
full value?

--  
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/a0a6773c-3360-44fa-9acf-62a7ac05149e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a0a6773c-3360-44fa-9acf-62a7ac05149e%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [July 9, 2014, 5:16pm UTC](https://discuss.elastic.co/t/aggregations-and-special-characters/18559/2 "2014-07-09T17:16:21Z")

</div>

Aggregations work on the tokens for the specified field. These tokens are  
generated when a tokenizer is applied to a field. In your case, you do not  
want the field to be tokenized at all, so you would either need to define  
is as not\_analyzed or use a keyword tokenizer, which does not separate  
tokens.

> **[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.

> **[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.

> **[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.

Cheers,

Ivan

On Wed, Jul 9, 2014 at 10:08 AM, Lucas Rutledge [lrutledge1@gmail.com](mailto:lrutledge1@gmail.com)  
wrote:

> I am performing an terms aggregation on a query to return the unique  
> values of a field, in this case the field being emails in the format  
> [example@gmail.com](mailto:example@gmail.com) or [example@aaa.example.com](mailto:example@aaa.example.com).
> 
> "aggregations": {  
> "users\_overall": {  
> "terms": {  
> "field": "email"  
> }  
> }  
> }  
> Instead of receiving back the full unique emails that I need I get results  
> such as these:
> 
> - {
> - 
> - key: [gmail.com](http://gmail.com)
> - doc\_count: 121864  
> }
> 
> - {
> - key: [yahoo.com](http://yahoo.com)
> - doc\_count: 68648  
> }
> 
> - {
> - key: [roadrunner.com](http://roadrunner.com)
> - doc\_count: 58194  
> }
> 
> - {
> - key: [optimum.net](http://optimum.net)
> - doc\_count: 35162  
> }
> 
> - {
> - key: [hotmail.com](http://hotmail.com)
> - doc\_count: 31407  
> }
> 
> - {
> - key: [nyc.rr.com](http://nyc.rr.com)
> - doc\_count: 24010  
> }
> 
> - {
> - key: [aol.com](http://aol.com)
> - doc\_count: 22502  
> }
> 
> - 
> - I've run into this problem with other fields that have values with  
> special characters in them as well, is there any way to perform an  
> aggregation like this that can ignore the special characters and return the  
> full value?
> 
> --  
> 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/a0a6773c-3360-44fa-9acf-62a7ac05149e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a0a6773c-3360-44fa-9acf-62a7ac05149e%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/a0a6773c-3360-44fa-9acf-62a7ac05149e%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/a0a6773c-3360-44fa-9acf-62a7ac05149e%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [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/CALY%3DcQBcBj0MWgtuxK1P3gdp9\_9HHBXi33%3D%2BqTrOtQx5q%3Dk5ag%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQBcBj0MWgtuxK1P3gdp9_9HHBXi33%3D%2BqTrOtQx5q%3Dk5ag%40mail.gmail.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:16am UTC](https://discuss.elastic.co/t/aggregations-and-special-characters/18559/3 "2017-07-06T01:16:59Z")

</div>


