# Combining stopwords with filter in an Analyzer

**URL:** <https://discuss.elastic.co/t/combining-stopwords-with-filter-in-an-analyzer/22353>\
**Category:** Elasticsearch\
**Created:** [February 24, 2015, 12:04pm UTC](https://discuss.elastic.co/t/combining-stopwords-with-filter-in-an-analyzer/22353 "2015-02-24T12:04:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cornet\_remi](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@cornet\_remi](https://discuss.elastic.co/u/cornet_remi)\
**Post date:** [February 24, 2015, 12:04pm UTC](https://discuss.elastic.co/t/combining-stopwords-with-filter-in-an-analyzer/22353/1 "2015-02-24T12:04:47Z")

</div>

Hello,

I'm trying to combine the Stopwords functionnality of an Analyzer with a  
Synonym filter. They work separatly but I can't manage to make them work  
together.

So I create an index (index3) and set an analyzer which remove little dutch  
words, It's working : In the following example, "de" and "het" are removed,

PUT /index3  
{  
"settings": {  
"analysis": {  
"analyzer": {  
"du\_analyzer": {  
"type": "standard",  
"stopwords" : "_dutch_"  
}  
}  
}  
}  
}

GET /index3/\_analyze?analyzer=du\_analyzer  
{  
het de universe  
}

Results :

{  
"tokens": [  
{  
"token": "universe",  
"start\_offset": 14,  
"end\_offset": 22,  
"type": "",  
"position": 3  
}  
]  
}

When I try to add a Synonym Filter, it works but the Stopwords  
functionnality stop working... Like in the following example ("universe"  
become "cosmos" but "het" and "de" are still there)

PUT /index2  
{  
"settings": {  
"analysis": {  
"filter": {  
"synonym" : {  
"type" : "synonym",  
"synonyms\_path" : "analysis/synonym.txt"  
}  
},  
"analyzer": {  
"du\_analyzer": {  
"type": "custom",  
"tokenizer": "standard",  
"stopwords" : "_dutch_",  
"filter": ["synonym"]  
}  
}  
}  
}  
}

GET /index2/\_analyze?analyzer=du\_analyzer  
{  
het de universe  
}

Results :

{  
"tokens": [  
{  
"token": "het",  
"start\_offset": 7,  
"end\_offset": 10,  
"type": "",  
"position": 1  
},  
{  
"token": "de",  
"start\_offset": 11,  
"end\_offset": 13,  
"type": "",  
"position": 2  
},  
{  
"token": "cosmos",  
"start\_offset": 14,  
"end\_offset": 22,  
"type": "SYNONYM",  
"position": 3  
}  
]  
}

Anyone know why my request behaves like this?

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/42fb605b-27da-43ca-b1a7-d4d2b291e75f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/42fb605b-27da-43ca-b1a7-d4d2b291e75f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![cornet\_remi](https://avatars.discourse-cdn.com/v4/letter/c/a3d4f5/32.png) [@cornet\_remi](https://discuss.elastic.co/u/cornet_remi)\
**Post date:** [February 24, 2015, 12:27pm UTC](https://discuss.elastic.co/t/combining-stopwords-with-filter-in-an-analyzer/22353/2 "2015-02-24T12:27:25Z")

</div>

Ok, I found my error. stopwords is also a filter... Here is the solution

PUT /index4  
{  
"settings": {  
"analysis": {  
"filter": {  
"synonym" : {  
"type" : "synonym",  
"synonyms\_path" : "analysis/synonym.txt"  
},  
"du\_stop" : {  
"type" : "stop",  
"stopwords" : "_dutch_"  
}  
},  
"analyzer": {  
"du\_analyzer": {  
"type": "custom",  
"tokenizer": "standard",  
"filter": ["synonym", "du\_stop"]  
}  
}  
}  
}  
}

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/3251e032-dc61-45b6-9cfb-57d2395ae626%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3251e032-dc61-45b6-9cfb-57d2395ae626%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:30am UTC](https://discuss.elastic.co/t/combining-stopwords-with-filter-in-an-analyzer/22353/3 "2017-07-06T00:30:31Z")

</div>


