# Terms Aggregation skips dot(.) character

**URL:** <https://discuss.elastic.co/t/terms-aggregation-skips-dot-character/145864>\
**Category:** Elasticsearch\
**Created:** [August 24, 2018, 7:44am UTC](https://discuss.elastic.co/t/terms-aggregation-skips-dot-character/145864 "2018-08-24T07:44:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jithintk.speridian](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jithintk.speridian/32/34784_2.png) [@jithintk.speridian](https://discuss.elastic.co/u/jithintk.speridian)\
**Post date:** [August 24, 2018, 7:44am UTC](https://discuss.elastic.co/t/terms-aggregation-skips-dot-character/145864/1 "2018-08-24T07:44:13Z")

</div>

Hi All,

I am facing an issue with elastic search, but not able to fix it for last two days.

I have a document product with a field list dynamicAttributes.  
e.g.  
dynamicAttributeValues": [  
"S",  
"Blue Ridge",  
"10.5",  
"10",  
"11.5",  
"11.5",  
"6.5",  
"6",  
"5",  
"5.5",  
"Large",  
"XLarge"  
]

I want to aggregate the result with doc\_count which I am able to do. But the weird thing I noticed that **terms aggregation is skipping the dot('.') character** as the aggregation coming as below  
{  
"size": "65",  
"count": 15437  
},  
{  
"size": "13",  
"count": 10679  
},  
{  
"size": "105",  
"count": 9651  
},  
{  
"size": "55",  
"count": 9359  
}

we are getting 65 instead of 6.5, 105 instead of 10.5.... !!!!!

I googled, binged and searched everywhere but couldn't get a resolution to this.

## Please help on this

Thanks  
Jithin Kuriakose

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [September 4, 2018, 1:33pm UTC](https://discuss.elastic.co/t/terms-aggregation-skips-dot-character/145864/2 "2018-09-04T13:33:30Z")

</div>

The issue is actually with the mapping, not necessarily the terms aggregation. Terms aggs work on the post-analysis form of the the field. So in this case, the field likely has an analyzer that tokenizes on special characters (`standard` analyzer does this). So when `5.5` is tokenized by the analyzer, it gets turned into `["5", "5"]` instead of `"5.5"`.

So when the terms agg starts working on the data, it is seeing `"5"` individually and the periods are lost.

The solution is to map your field as a `keyword` instead of `text`. Keyword fields are not analyzed, so the token being aggregated is identical to the original token.

`text` fields are more for search, `keyword` more for aggs. Generally 🙂

---

<div class="post-metadata">

**Author:** ![jithintk.speridian](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jithintk.speridian/32/34784_2.png) [@jithintk.speridian](https://discuss.elastic.co/u/jithintk.speridian)\
**Post date:** [September 8, 2018, 12:33pm UTC](https://discuss.elastic.co/t/terms-aggregation-skips-dot-character/145864/3 "2018-09-08T12:33:26Z")

</div>

Hi @polyfractal,  
Thanks for your response.  
The actual issue seems to be different for me.  
I have added a new multi raw field, which is not analyzed. Now I am aggregating on productSkuDynamicAttributeValues.raw field  
But still there are still some problems.

Below are my new mapping on the field.  
"productSkuDynamicAttributeValues": {  
"type": "string",  
"fields": {  
"high\_precision": {  
"type": "string",  
"analyzer": "high\_precision\_analyzer"  
},  
"raw": {  
"type": "string",  
"index": "not\_analyzed"  
},  
"word\_proximity": {  
"type": "string",  
"analyzer": "word\_proximity\_analyzer"  
}  
},  
"analyzer": "high\_recall\_analyzer"  
},

I have a value "0-6 months", but in aggregation I am getting "06"... !!!!

Could you please help me on this?

Thanks  
Jithin

---

<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:** [October 6, 2018, 12:33pm UTC](https://discuss.elastic.co/t/terms-aggregation-skips-dot-character/145864/4 "2018-10-06T12:33:32Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
