# Aggregations search results are always lowercase

**URL:** <https://discuss.elastic.co/t/aggregations-search-results-are-always-lowercase/136868>\
**Category:** Elasticsearch\
**Created:** [June 21, 2018, 1:02pm UTC](https://discuss.elastic.co/t/aggregations-search-results-are-always-lowercase/136868 "2018-06-21T13:02:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_M](https://avatars.discourse-cdn.com/v4/letter/m/a9adbd/32.png) [@Martin\_M](https://discuss.elastic.co/u/Martin_M)\
**Post date:** [June 21, 2018, 1:02pm UTC](https://discuss.elastic.co/t/aggregations-search-results-are-always-lowercase/136868/1 "2018-06-21T13:02:05Z")

</div>

Hi,

I have an issue regarding the aggregations search. I've already tried several analyzer and settings in my template/mapping, but the values I get are always in lowercase.

How should a template and a search look like?

> **Template (only a small part)**
>
> {  
> "index\_patterns": "obpd\_\*",  
> "settings": {  
> "index": {  
> "mapping": {  
> "ignore\_malformed": "true"  
> },  
> "analysis": {  
> "analyzer": {  
> "autocomplete": {  
> "type": "custom",  
> "filter": ["lowercase"],  
> "tokenizer": "ngram\_tokenizer"  
> },  
> "test": {  
> "type": "pattern",  
> "lowercase": false,  
> "tokenizer": "ngram\_tokenizer"  
> }  
> },  
> "tokenizer": {  
> "ngram\_tokenizer": {  
> "type": "ngram",  
> "min\_gram": "3",  
> "max\_gram": "3",  
> "token\_chars": ["letter",  
> "digit"]  
> }  
> }  
> },  
> "number\_of\_shards": "1",  
> "number\_of\_replicas": "0"  
> }  
> },  
> "mappings": {  
> "obpd": {  
> "\_routing": {  
> "required": true  
> },  
> "dynamic\_templates": [{  
> "prat\_name": {  
> "mapping": {  
> "fielddata": true,  
> "fields": {  
> "raw": {  
> "type": "keyword"  
> }  
> },  
> "type": "text"  
> },  
> "match": "prat\_name"  
> }  
> },  
> {  
> "hierarchy\_names": {  
> "match": "hierarchy\_names",  
> "mapping": {  
> "fields": {  
> "autocomplete": {  
> "search\_analyzer": "standard",  
> "analyzer": "simple",  
> "type": "text",  
> "fielddata": true  
> },  
> "raw": {  
> "type": "keyword",  
> "search\_analyzer": "test",  
> "analyzer": "test"  
> }  
> },  
> "type": "text",  
> "fielddata": true,  
> "search\_analyzer": "test",  
> "analyzer": "test"  
> }  
> }  
> },  
> {  
> "hierarchy\_ids": {  
> "mapping": {  
> "fielddata": true,  
> "fields": {  
> ...

> **Document:**
>
> {  
> "\_index": "obpd\_deu\_deu",  
> "\_type": "obpd",  
> "\_id": "3000000000",  
> "\_score": 0.6931472,  
> "\_routing": "3000000000",  
> "\_source": {  
> "type": "productdata",  
> "parent\_child\_relation": "productdata",  
> "epimId": 3000000000,  
> "obje\_id": 3000000050,  
> "epob\_type\_Id": 2020,  
> "lang\_id": 2,  
> "lang\_iso": "deu\_DEU",  
> "clie\_id": 1,  
> "name": "MM\_Prod",  
> ...,  
> ...,   
> "product\_change\_date\_ordernr": "2018-03-13T09:55:13",  
> "product\_change\_date\_productnr": "2018-03-13T10:15:37",  
> "product\_image\_obje\_id": null,  
> "hierarchy\_ids": "3000000006:3000000020",  
> "hierarchy\_names": "MMTest:MMTestGrp",  
> "workflows": [  
> ...  
> }

> **Query (from Kibana)**
>
> GET obpd\_deu\_deu/\_search  
> {  
> "aggs" : {  
> "MM\_Test" : {  
> "terms" : { "field" : "hierarchy\_names.raw" }  
> }  
> }  
> }
> 
> or
> 
> GET obpd\_deu\_deu/\_search  
> {  
> "size": 0,  
> "aggs": {  
> "mm\_test": {  
> "terms": {  
> "field": "hierarchy\_names.raw"  
> },  
> "aggs": {  
> "mm\_test2": {  
> "terms": {  
> "field": "hierarchy\_names",  
> "size": 1  
> }  
> }  
> }  
> }  
> }  
> }

> **Result**
>
> "aggregations": {  
> "mm\_test": {  
> "doc\_count\_error\_upper\_bound": 0,  
> "sum\_other\_doc\_count": 0,  
> "buckets": [  
> {  
> "key": "mmtest:mmtestgrp",  
> "doc\_count": 2,  
> "mm\_test2": {  
> "doc\_count\_error\_upper\_bound": 0,  
> "sum\_other\_doc\_count": 0,  
> "buckets": [  
> {  
> "key": "mmtest:mmtestgrp",  
> "doc\_count": 2  
> }  
> ]  
> }  
> }  
> ]  
> }  
> }

As you can see, my document holds this "hierarchy\_names": "MMTest:MMTestGrp", and the query returns this "key": "mmtest:mmtestgrp".  
And I just can't figure out what is wrong.

Thanks  
Martin

---

<div class="post-metadata">

**Author:** ![Martin\_M](https://avatars.discourse-cdn.com/v4/letter/m/a9adbd/32.png) [@Martin\_M](https://discuss.elastic.co/u/Martin_M)\
**Post date:** [June 21, 2018, 2:38pm UTC](https://discuss.elastic.co/t/aggregations-search-results-are-always-lowercase/136868/2 "2018-06-21T14:38:07Z")

</div>

I've found the issue. The analyzer was specified correctly. But in my template was a second mapping for "hierarchy\_names" that was specified with the simple analyzer. That mapping was always applied and that's why my changes were not considered at all.

If someone wants to know more, I can explain it in more detail.

---

<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 19, 2018, 2:38pm UTC](https://discuss.elastic.co/t/aggregations-search-results-are-always-lowercase/136868/3 "2018-07-19T14:38:07Z")

</div>

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