# Mappings for stemming

**URL:** <https://discuss.elastic.co/t/mappings-for-stemming/13809>\
**Category:** Elasticsearch\
**Created:** [October 1, 2013, 12:16am UTC](https://discuss.elastic.co/t/mappings-for-stemming/13809 "2013-10-01T00:16:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Richard\_Tier](https://avatars.discourse-cdn.com/v4/letter/r/a88e57/32.png) [@Richard\_Tier](https://discuss.elastic.co/u/Richard_Tier)\
**Post date:** [October 1, 2013, 12:16am UTC](https://discuss.elastic.co/t/mappings-for-stemming/13809/1 "2013-10-01T00:16:25Z")

</div>

I would like to do some stemming, so - for example -"flash cards" and  
"flash card" are stemmed to same roots and so return same results (i  
appreciate its not an exact science with stemming and my milage may vary).

On the desired field ('description') I set a custom analyzer  
('my\_analyzer') which uses custom filters.

When I run the following query I get hits (great), but "flash cards" and  
"flash card" each return different results:

{"query\_string": {  
"fields": ["description"],  
"query": query  
}  
}

but when I run the following query I get no results :

{"query\_string": {  
"fields": ["description.analyzed"],  
"query": query  
}  
}

Looking at my mapping below, we see that description.analyzed and  
description have the same config (I did this for testing) - so each field  
should behave the same, and stemming should happen.

How can I be sure that the analyzer is being used?

How can I make description.analyzed query work?

How can I be sure stemming is working?

my mappings for the index:

{'mappings': {  
'file': { # doc\_type  
'properties': { # properties for doc\_type  
'description': { # field called description  
'type': 'multi\_field', # to allow "sub fields" with different alalysers  
'fields': {  
'description': {'type': 'string', 'analyzer': 'my\_analyser'},  
'analysed': {'type': 'string', 'analyzer': 'my\_analyser'}  
}  
},  
}  
}  
},  
'settings': {  
'analysis': {  
'filter': { #declare my custin filters  
'filter\_ngrams': {'max\_gram': 5, 'min\_gram': 1, 'type': 'edgeNGram'},  
'filter\_stop':{'type':'stop', 'enable\_position\_increments': 'false'},  
'filter\_shingle':{'type': 'shingle', 'max\_shingle\_size': 5, 'min\_shingle\_size': 2, 'output\_unigrams':'true'},  
'filter\_stemmer' : {'type': 'stemmer', 'name': 'english'}  
},  
'analyzer': { # declare custom analyzers  
'my\_analyser': {  
'filter': ['standard', 'lowercase', 'asciifolding', 'filter\_stop', 'filter\_shingle', 'filter\_stemmer'],  
'type': 'custom',  
'tokenizer': 'standard'  
},  
}  
}  
}  
}}

Thanks 🙂

--  
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:** ![Richard\_Tier](https://avatars.discourse-cdn.com/v4/letter/r/a88e57/32.png) [@Richard\_Tier](https://discuss.elastic.co/u/Richard_Tier)\
**Post date:** [October 1, 2013, 1:34am UTC](https://discuss.elastic.co/t/mappings-for-stemming/13809/2 "2013-10-01T01:34:16Z")

</div>

I now see I had not properly set the mappings displayed - so the solution  
was to use put mappings.

On Tuesday, October 1, 2013 1:16:25 AM UTC+1, Richard Tier wrote:

> I would like to do some stemming, so - for example -"flash cards" and  
> "flash card" are stemmed to same roots and so return same results (i  
> appreciate its not an exact science with stemming and my milage may vary).
> 
> On the desired field ('description') I set a custom analyzer  
> ('my\_analyzer') which uses custom filters.
> 
> When I run the following query I get hits (great), but "flash cards" and  
> "flash card" each return different results:
> 
> {"query\_string": {  
> "fields": ["description"],  
> "query": query  
> }  
> }
> 
> but when I run the following query I get no results :
> 
> {"query\_string": {  
> "fields": ["description.analyzed"],  
> "query": query  
> }  
> }
> 
> Looking at my mapping below, we see that description.analyzed and  
> description have the same config (I did this for testing) - so each field  
> should behave the same, and stemming should happen.
> 
> How can I be sure that the analyzer is being used?
> 
> How can I make description.analyzed query work?
> 
> How can I be sure stemming is working?
> 
> my mappings for the index:
> 
> {'mappings': {  
> 'file': { # doc\_type  
> 'properties': { # properties for doc\_type  
> 'description': { # field called description  
> 'type': 'multi\_field', # to allow "sub fields" with different alalysers  
> 'fields': {  
> 'description': {'type': 'string', 'analyzer': 'my\_analyser'},  
> 'analysed': {'type': 'string', 'analyzer': 'my\_analyser'}  
> }  
> },  
> }  
> }  
> },  
> 'settings': {  
> 'analysis': {  
> 'filter': { #declare my custin filters  
> 'filter\_ngrams': {'max\_gram': 5, 'min\_gram': 1, 'type': 'edgeNGram'},  
> 'filter\_stop':{'type':'stop', 'enable\_position\_increments': 'false'},  
> 'filter\_shingle':{'type': 'shingle', 'max\_shingle\_size': 5, 'min\_shingle\_size': 2, 'output\_unigrams':'true'},  
> 'filter\_stemmer' : {'type': 'stemmer', 'name': 'english'}  
> },  
> 'analyzer': { # declare custom analyzers  
> 'my\_analyser': {  
> 'filter': ['standard', 'lowercase', 'asciifolding', 'filter\_stop', 'filter\_shingle', 'filter\_stemmer'],  
> 'type': 'custom',  
> 'tokenizer': 'standard'  
> },  
> }  
> }  
> }  
> }}
> 
> Thanks 🙂

--  
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:** ![sina\_tamanna](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@sina\_tamanna](https://discuss.elastic.co/u/sina_tamanna)\
**Post date:** [October 1, 2013, 7:00am UTC](https://discuss.elastic.co/t/mappings-for-stemming/13809/3 "2013-10-01T07:00:01Z")

</div>

Great that you found the solution. Just as a hint, to debug such problems  
it might help to look into Analyze API[http://www.elasticsearch.org/guide/reference/api/admin-indices-analyze/](http://www.elasticsearch.org/guide/reference/api/admin-indices-analyze/).  
You could chose which field's analyzer you want to use and verify it though  
this API.

--  
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:14am UTC](https://discuss.elastic.co/t/mappings-for-stemming/13809/4 "2017-07-06T02:14:08Z")

</div>


