# Mapping not analyzed field, but making it not case sensitive

**URL:** <https://discuss.elastic.co/t/mapping-not-analyzed-field-but-making-it-not-case-sensitive/5975>\
**Category:** Elasticsearch\
**Created:** [November 25, 2011, 9:42pm UTC](https://discuss.elastic.co/t/mapping-not-analyzed-field-but-making-it-not-case-sensitive/5975 "2011-11-25T21:42:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eugene\_Strokin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eugene_strokin/32/1238_2.png) [@Eugene\_Strokin](https://discuss.elastic.co/u/Eugene_Strokin)\
**Post date:** [November 25, 2011, 9:42pm UTC](https://discuss.elastic.co/t/mapping-not-analyzed-field-but-making-it-not-case-sensitive/5975/1 "2011-11-25T21:42:41Z")

</div>

Hello, I'm trying to migrate from Solr, but I'm having trouble  
understanding mapping in ES.  
I need to have just a plain string field for things like user name or  
category name. But it could be not case sensetive.  
So if I have a field with value like "userName":"Eugene Strokin" the  
document should be returned in search like this: "userName":"eugene  
strokin", as well as "userName":"EUGENE Strokin", and  
"userName":"EugEne StrOKin"  
I've put a mapping file with field description:  
"userName":{"type":"string", index:"not\_analyzed"},  
But of course it is case sensitive.  
So, query like this will not return anything:  
{  
"filtered" : {  
"query" : {  
"match\_all" : {  
}  
},  
"filter" : {  
"term" : {  
"userName" : "tessa"  
}  
}  
}  
}  
if user name spelled using wrong case.  
Could you please let me know how to mapped not case sensitive strings?

Thank you,  
Eugene S.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [November 28, 2011, 11:58am UTC](https://discuss.elastic.co/t/mapping-not-analyzed-field-but-making-it-not-case-sensitive/5975/2 "2011-11-28T11:58:00Z")

</div>

You can configure an analyzer with keyword tokenizer and lowercase filter,  
call it "keyword\_lowercase" or something similar, and then, map the  
relevant fields with this analyzer.

On Fri, Nov 25, 2011 at 11:42 PM, Eugene Strokin [eugene@strokin.info](mailto:eugene@strokin.info)wrote:

> Hello, I'm trying to migrate from Solr, but I'm having trouble  
> understanding mapping in ES.  
> I need to have just a plain string field for things like user name or  
> category name. But it could be not case sensetive.  
> So if I have a field with value like "userName":"Eugene Strokin" the  
> document should be returned in search like this: "userName":"eugene  
> strokin", as well as "userName":"EUGENE Strokin", and  
> "userName":"EugEne StrOKin"  
> I've put a mapping file with field description:  
> "userName":{"type":"string", index:"not\_analyzed"},  
> But of course it is case sensitive.  
> So, query like this will not return anything:  
> {  
> "filtered" : {  
> "query" : {  
> "match\_all" : {  
> }  
> },  
> "filter" : {  
> "term" : {  
> "userName" : "tessa"  
> }  
> }  
> }  
> }  
> if user name spelled using wrong case.  
> Could you please let me know how to mapped not case sensitive strings?
> 
> Thank you,  
> Eugene S.

---

<div class="post-metadata">

**Author:** ![Eugene\_Strokin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eugene_strokin/32/1238_2.png) [@Eugene\_Strokin](https://discuss.elastic.co/u/Eugene_Strokin)\
**Post date:** [November 29, 2011, 12:40am UTC](https://discuss.elastic.co/t/mapping-not-analyzed-field-but-making-it-not-case-sensitive/5975/3 "2011-11-29T00:40:39Z")

</div>

Is anyway to define this new type on some configuration file?  
I'm trying to put:  
index :  
analysis:  
analyzer:  
string\_lowercase:  
tokenizer : keyword  
filter : lowercase

in config/elasticsearch.yml file which is under config folder, but I  
keep getting  
Caused by: org.elasticsearch.index.mapper.MapperParsingException: No  
handler for type [string\_lowercase] declared on field [screenName]

Thank you,  
E.S.

On Nov 28, 6:58 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> You can configure an analyzer with keyword tokenizer and lowercase filter,  
> call it "keyword\_lowercase" or something similar, and then, map the  
> relevant fields with this analyzer.
> 
> On Fri, Nov 25, 2011 at 11:42 PM, Eugene Strokin [eug...@strokin.info](mailto:eug...@strokin.info)wrote:
> 
> > Hello, I'm trying to migrate from Solr, but I'm having trouble  
> > understanding mapping in ES.  
> > I need to have just a plain string field for things like user name or  
> > category name. But it could be not case sensetive.  
> > So if I have a field with value like "userName":"Eugene Strokin" the  
> > document should be returned in search like this: "userName":"eugene  
> > strokin", as well as "userName":"EUGENE Strokin", and  
> > "userName":"EugEne StrOKin"  
> > I've put a mapping file with field description:  
> > "userName":{"type":"string", index:"not\_analyzed"},  
> > But of course it is case sensitive.  
> > So, query like this will not return anything:  
> > {  
> > "filtered" : {  
> > "query" : {  
> > "match\_all" : {  
> > }  
> > },  
> > "filter" : {  
> > "term" : {  
> > "userName" : "tessa"  
> > }  
> > }  
> > }  
> > }  
> > if user name spelled using wrong case.  
> > Could you please let me know how to mapped not case sensitive strings?
> 
> > Thank you,  
> > Eugene S.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [November 29, 2011, 7:45am UTC](https://discuss.elastic.co/t/mapping-not-analyzed-field-but-making-it-not-case-sensitive/5975/4 "2011-11-29T07:45:40Z")

</div>

Seems to work: [config · GitHub](https://gist.github.com/1403902). Are you sure you configured  
the yml correctly?

On Tue, Nov 29, 2011 at 2:40 AM, Eugene Strokin [eugene@strokin.info](mailto:eugene@strokin.info) wrote:

> Is anyway to define this new type on some configuration file?  
> I'm trying to put:  
> index :  
> analysis:  
> analyzer:  
> string\_lowercase:  
> tokenizer : keyword  
> filter : lowercase
> 
> in config/elasticsearch.yml file which is under config folder, but I  
> keep getting  
> Caused by: org.elasticsearch.index.mapper.MapperParsingException: No  
> handler for type [string\_lowercase] declared on field [screenName]
> 
> Thank you,  
> E.S.
> 
> On Nov 28, 6:58 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > You can configure an analyzer with keyword tokenizer and lowercase  
> > filter,  
> > call it "keyword\_lowercase" or something similar, and then, map the  
> > relevant fields with this analyzer.
> > 
> > On Fri, Nov 25, 2011 at 11:42 PM, Eugene Strokin \<eug...@strokin.info  
> > wrote:
> > 
> > > Hello, I'm trying to migrate from Solr, but I'm having trouble  
> > > understanding mapping in ES.  
> > > I need to have just a plain string field for things like user name or  
> > > category name. But it could be not case sensetive.  
> > > So if I have a field with value like "userName":"Eugene Strokin" the  
> > > document should be returned in search like this: "userName":"eugene  
> > > strokin", as well as "userName":"EUGENE Strokin", and  
> > > "userName":"EugEne StrOKin"  
> > > I've put a mapping file with field description:  
> > > "userName":{"type":"string", index:"not\_analyzed"},  
> > > But of course it is case sensitive.  
> > > So, query like this will not return anything:  
> > > {  
> > > "filtered" : {  
> > > "query" : {  
> > > "match\_all" : {  
> > > }  
> > > },  
> > > "filter" : {  
> > > "term" : {  
> > > "userName" : "tessa"  
> > > }  
> > > }  
> > > }  
> > > }  
> > > if user name spelled using wrong case.  
> > > Could you please let me know how to mapped not case sensitive strings?
> > 
> > > Thank you,  
> > > Eugene S.

---

<div class="post-metadata">

**Author:** ![vaibhav\_saini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vaibhav_saini/32/2798_2.png) [@vaibhav\_saini](https://discuss.elastic.co/u/vaibhav_saini)\
**Post date:** [July 24, 2012, 7:18pm UTC](https://discuss.elastic.co/t/mapping-not-analyzed-field-but-making-it-not-case-sensitive/5975/5 "2012-07-24T19:18:40Z")

</div>

HI Kimchy,  
I tried your gist and it gave me following exception

{"error":"RemoteTransportException[[Banner, Robert  
Bruce][inet[/192.168.1.15:9300]][indices/create]]; nested:  
MapperParsingException[mapping [type1]]; nested:  
MapperParsingException[Analyzer [string\_lowercase] not found for field  
[field1]];

I first created the analyzer in the elasticsearch.yml ,as provided in your  
gist, and after that I created the mapping. Please let me know what I am  
doing wrong.

On Tuesday, 29 November 2011 13:15:40 UTC+5:30, kimchy wrote:

> Seems to work: [config · GitHub](https://gist.github.com/1403902). Are you sure you  
> configured the yml correctly?
> 
> On Tue, Nov 29, 2011 at 2:40 AM, Eugene Strokin [eugene@strokin.info](mailto:eugene@strokin.info)wrote:
> 
> > Is anyway to define this new type on some configuration file?  
> > I'm trying to put:  
> > index :  
> > analysis:  
> > analyzer:  
> > string\_lowercase:  
> > tokenizer : keyword  
> > filter : lowercase
> > 
> > in config/elasticsearch.yml file which is under config folder, but I  
> > keep getting  
> > Caused by: org.elasticsearch.index.mapper.MapperParsingException: No  
> > handler for type [string\_lowercase] declared on field [screenName]
> > 
> > Thank you,  
> > E.S.
> > 
> > On Nov 28, 6:58 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> > 
> > > You can configure an analyzer with keyword tokenizer and lowercase  
> > > filter,  
> > > call it "keyword\_lowercase" or something similar, and then, map the  
> > > relevant fields with this analyzer.
> > > 
> > > On Fri, Nov 25, 2011 at 11:42 PM, Eugene Strokin \<eug...@strokin.info  
> > > wrote:
> > > 
> > > > Hello, I'm trying to migrate from Solr, but I'm having trouble  
> > > > understanding mapping in ES.  
> > > > I need to have just a plain string field for things like user name or  
> > > > category name. But it could be not case sensetive.  
> > > > So if I have a field with value like "userName":"Eugene Strokin" the  
> > > > document should be returned in search like this: "userName":"eugene  
> > > > strokin", as well as "userName":"EUGENE Strokin", and  
> > > > "userName":"EugEne StrOKin"  
> > > > I've put a mapping file with field description:  
> > > > "userName":{"type":"string", index:"not\_analyzed"},  
> > > > But of course it is case sensitive.  
> > > > So, query like this will not return anything:  
> > > > {  
> > > > "filtered" : {  
> > > > "query" : {  
> > > > "match\_all" : {  
> > > > }  
> > > > },  
> > > > "filter" : {  
> > > > "term" : {  
> > > > "userName" : "tessa"  
> > > > }  
> > > > }  
> > > > }  
> > > > }  
> > > > if user name spelled using wrong case.  
> > > > Could you please let me know how to mapped not case sensitive strings?
> > > 
> > > > Thank you,  
> > > > Eugene S.

---

<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, 3:19am UTC](https://discuss.elastic.co/t/mapping-not-analyzed-field-but-making-it-not-case-sensitive/5975/6 "2017-07-06T03:19:14Z")

</div>


