# Facets problem with capital letters

**URL:** https://discuss.elastic.co/t/facets-problem-with-capital-letters/10757
**Category:** Elasticsearch
**Created:** [February 15, 2013, 6:26pm UTC](https://discuss.elastic.co/t/facets-problem-with-capital-letters/10757 "2013-02-15T18:26:58Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![elastray](https://avatars.discourse-cdn.com/v4/letter/e/6de8d8/32.png) [@elastray](https://discuss.elastic.co/u/elastray)
#### Post date: [February 15, 2013, 6:26pm UTC](https://discuss.elastic.co/t/facets-problem-with-capital-letters/10757/1 "2013-02-15T18:26:58Z")

</div>

Hi,

I am getting the facets in a search, but I have a problem, the capital letters of the terms are always lowercase, so Elastic Search and the app I am trying to integrate can't understand each other (actually, the app can't understand ES).

I mean, I get something like

"facets":{  
"name":{"\_type":"terms","missing":0,"total":9,"other":0,"terms":[  
{"term":"myownfile","count":6},  
{"term":"myarticle","count":2},  
{"term":"mypost","count":1}  
]}  
}

when it should be

"facets":{  
"name":{"\_type":"terms","missing":0,"total":9,"other":0,"terms":[  
{"term":"myOwnFile","count":6},  
{"term":"myArticle","count":2},  
{"term":"myPost","count":1}  
]}  
}

I checked that I am storing "myOwnFile", "myArticle" and "myPost" from the app in ES.

How can I fix that?

Thanks!!

---

<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 15, 2013, 6:35pm UTC](https://discuss.elastic.co/t/facets-problem-with-capital-letters/10757/2 "2013-02-15T18:35:23Z")

</div>

You have to change the mapping for these fields and for example use a Keyword analyzer: [Elastic — The Search AI Company | Elastic](http://www.elasticsearch.org/guide/reference/index-modules/analysis/keyword-analyzer.html)

## HTH

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

Le 15 févr. 2013 à 19:26, elastray [adelpozo@xtivia.com](mailto:adelpozo@xtivia.com) a écrit :

> Hi,
> 
> I am getting the facets in a search, but I have a problem, the capital  
> letters of the terms are always lowercase, so Elastic Search and the app I  
> am trying to integrate can't understand each other (actually, the app can't  
> understand ES).
> 
> I mean, I get something like
> 
> "facets":{  
> "name":{"\_type":"terms","missing":0,"total":9,"other":0,"terms":[  
> {"term":"myownfile","count":6},  
> {"term":"myarticle","count":2},  
> {"term":"mypost","count":1}  
> ]}  
> }
> 
> when it should be
> 
> "facets":{  
> "name":{"\_type":"terms","missing":0,"total":9,"other":0,"terms":[  
> {"term":"myOwnFile","count":6},  
> {"term":"myArticle","count":2},  
> {"term":"myPost","count":1}  
> ]}  
> }
> 
> I checked that I am storing "myOwnFile", "myArticle" and "myPost" from the  
> app in ES.
> 
> How can I fix that?
> 
> Thanks!!
> 
> --  
> View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/Facets-problem-with-capital-letters-tp4029894.html](http://elasticsearch-users.115913.n3.nabble.com/Facets-problem-with-capital-letters-tp4029894.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![elastray](https://avatars.discourse-cdn.com/v4/letter/e/6de8d8/32.png) [@elastray](https://discuss.elastic.co/u/elastray)
#### Post date: [February 15, 2013, 6:44pm UTC](https://discuss.elastic.co/t/facets-problem-with-capital-letters/10757/3 "2013-02-15T18:44:59Z")

</div>

The problem is that sometimes I will be able to map them correctly but others it is going to be impossible.

Could it be fixed using templates?

(mappings and templates was what was left for the end )

Thanks!!

---

<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 15, 2013, 6:47pm UTC](https://discuss.elastic.co/t/facets-problem-with-capital-letters/10757/4 "2013-02-15T18:47:37Z")

</div>

Not sure to understand your question here.

You can use multi field feature which is very cool for that.

Define whatever analyzer for your search and Keyword analyzer for facets.  
And compute facets on yourfield.facet.

Does it help?

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

Le 15 févr. 2013 à 19:35, David Pilato [david@pilato.fr](mailto:david@pilato.fr) a écrit :

> You have to change the mapping for these fields and for example use a Keyword analyzer: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/index-modules/analysis/keyword-analyzer.html)
> 
> ## HTH
> 
> David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
> @dadoonet | @elasticsearchfr | @scrutmydocs
> 
> Le 15 févr. 2013 à 19:26, elastray [adelpozo@xtivia.com](mailto:adelpozo@xtivia.com) a écrit :
> 
> > Hi,
> > 
> > I am getting the facets in a search, but I have a problem, the capital  
> > letters of the terms are always lowercase, so Elastic Search and the app I  
> > am trying to integrate can't understand each other (actually, the app can't  
> > understand ES).
> > 
> > I mean, I get something like
> > 
> > "facets":{  
> > "name":{"\_type":"terms","missing":0,"total":9,"other":0,"terms":[  
> > {"term":"myownfile","count":6},  
> > {"term":"myarticle","count":2},  
> > {"term":"mypost","count":1}  
> > ]}  
> > }
> > 
> > when it should be
> > 
> > "facets":{  
> > "name":{"\_type":"terms","missing":0,"total":9,"other":0,"terms":[  
> > {"term":"myOwnFile","count":6},  
> > {"term":"myArticle","count":2},  
> > {"term":"myPost","count":1}  
> > ]}  
> > }
> > 
> > I checked that I am storing "myOwnFile", "myArticle" and "myPost" from the  
> > app in ES.
> > 
> > How can I fix that?
> > 
> > Thanks!!
> > 
> > --  
> > View this message in context: [http://elasticsearch-users.115913.n3.nabble.com/Facets-problem-with-capital-letters-tp4029894.html](http://elasticsearch-users.115913.n3.nabble.com/Facets-problem-with-capital-letters-tp4029894.html)  
> > Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> > 
> > --  
> > 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).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![elastray](https://avatars.discourse-cdn.com/v4/letter/e/6de8d8/32.png) [@elastray](https://discuss.elastic.co/u/elastray)
#### Post date: [February 15, 2013, 7:47pm UTC](https://discuss.elastic.co/t/facets-problem-with-capital-letters/10757/5 "2013-02-15T19:47:45Z")

</div>

Perhaps the problem is that I am not sure if I understand the mappings.

What I am doing is replace Solr by ES. So I have the Solr schema and i have to create the mapping,

I have in Solr something like

description

with searchschemer I get

{  
"mappings" : {  
"type" : {  
"properties" : {  
"title" : { "type" : "string", "store" : "yes", "index" : "analyzed" },  
"description" : { "type" : "string", "store" : "yes", "index" : "analyzed" }  
},  
"dynamic\_templates" : [  
{  
"template\_" : {  
"match" : "\*Name",  
"match\_mapping\_type" : "string",  
"mapping" : { "type" : "string", "store" : "yes", "index" : "not\_analyzed" }  
}  
}  
]  
}  
}  
}

At this point, I do not understand

1. What happens with defaultSearchField. Perhaps it doesn't matter.
2. How I use the mapping? I don't get how map the type... I have a lot of different types of objects...
3. What I do with the dynamic\_templates.

Any help appreciated!!!  
Regards!

---

<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: [February 15, 2013, 8:04pm UTC](https://discuss.elastic.co/t/facets-problem-with-capital-letters/10757/6 "2013-02-15T20:04:43Z")

</div>

Your issue is that the field you facet on needs to be not\_analyzed, but  
sometimes you need this field to be analyzed as well. David's suggestion of  
multi field is the best solution:

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

Your mapping is syntactically correct, but needs to be modified. Are you  
faceting on the dynamic fields? I have never tried, but multi fields should  
work with dynamic templates.

"dynamic\_templates": [  
{  
"template\_": {  
"match": "\*Name",  
"match\_mapping\_type": "string",  
"mapping": {  
"type": "multi\_field",  
"fields": {  
"touched": { "type": "string", "index": "analyzed" },  
"untouched": { "type": "string", "index": "not\_analyzed" }  
}  
}  
}  
}  
]

The field names will change, so you need to adjust your queries.

--  
Ivan

On Fri, Feb 15, 2013 at 11:47 AM, elastray [adelpozo@xtivia.com](mailto:adelpozo@xtivia.com) wrote:

> Perhaps the problem is that I am not sure if I understand the mappings.
> 
> What I am doing is replace Solr by ES. So I have the Solr schema and i have  
> to create the mapping,
> 
> I have in Solr something like
> 
> description
> 
> with searchschemer I get
> 
> {  
> "mappings" : {  
> "type" : {  
> "properties" : {  
> "title" : { "type" : "string", "store" : "yes", "index" : "analyzed" },  
> "description" : { "type" : "string", "store" : "yes", "index" :  
> "analyzed"  
> }  
> },  
> "dynamic\_templates" : [  
> {  
> "template\_" : {  
> "match" : "\*Name",  
> "match\_mapping\_type" : "string",  
> "mapping" : { "type" : "string", "store" : "yes", "index" :  
> "not\_analyzed" }  
> }  
> }  
> ]  
> }  
> }  
> }
> 
> At this point, I do not understand
> 
> 1. What happens with defaultSearchField. Perhaps it doesn't matter.
> 2. How I use the mapping? I don't get how map the type... I have a lot of  
> different types of objects...
> 3. What I do with the dynamic\_templates.
> 
> Any help appreciated!!!  
> Regards!
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Facets-problem-with-capital-letters-tp4029894p4029901.html](http://elasticsearch-users.115913.n3.nabble.com/Facets-problem-with-capital-letters-tp4029894p4029901.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:51am UTC](https://discuss.elastic.co/t/facets-problem-with-capital-letters/10757/7 "2017-07-06T02:51:15Z")

</div>


