# Custom stop words in default\_search

**URL:** <https://discuss.elastic.co/t/custom-stop-words-in-default-search/7006>\
**Category:** Elasticsearch\
**Created:** [March 14, 2012, 5:51pm UTC](https://discuss.elastic.co/t/custom-stop-words-in-default-search/7006 "2012-03-14T17:51:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nurikabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nurikabe/32/2192_2.png) [@nurikabe](https://discuss.elastic.co/u/nurikabe)\
**Post date:** [March 14, 2012, 5:51pm UTC](https://discuss.elastic.co/t/custom-stop-words-in-default-search/7006/1 "2012-03-14T17:51:58Z")

</div>

Hi,

We are trying to set a custom list of stop words for default search by  
adding the following to elasticsearch.yml:

index:  
analysis:  
analyzer:  
default\_search:  
tokenizer: uax\_url\_email  
filter: [standard, lowercase, trim]  
stopwords: [email, telephone]

In other words, although we do want ElasticSearch to index tokens like  
"email" and "telephone", we want to prohibit searches on these words by  
default.

Querying:

{  
"query": {  
"query\_string": {  
"query": "email",  
"analyzer": "default\_search",  
"fields": [  
"file"  
]  
}  
}  
}

however pulls up all results that match "email". I notice that if we query  
on pre-defined stopwords such as "by" the query returns no results.

Am I doing something wrong in my stopwords definition that would cause my  
custom list to be ignored and defaults to be used instead?

Thanks

---

<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:** [March 16, 2012, 5:02pm UTC](https://discuss.elastic.co/t/custom-stop-words-in-default-search/7006/2 "2012-03-16T17:02:05Z")

</div>

You don't have a stop words filter defined in teh filter list. What you  
need to do is default a custom filter based on the stop token filter (  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/index-modules/analysis/stop-tokenfilter.html)),  
name it something like "my\_stop", and then list it in the list of filters  
for default\_search.

On Wed, Mar 14, 2012 at 7:51 PM, nurikabe [eaowens@gmail.com](mailto:eaowens@gmail.com) wrote:

> Hi,
> 
> We are trying to set a custom list of stop words for default search by  
> adding the following to elasticsearch.yml:
> 
> index:  
> analysis:  
> analyzer:  
> default\_search:  
> tokenizer: uax\_url\_email  
> filter: [standard, lowercase, trim]  
> stopwords: [email, telephone]
> 
> In other words, although we do want Elasticsearch to index tokens like  
> "email" and "telephone", we want to prohibit searches on these words by  
> default.
> 
> Querying:
> 
> {  
> "query": {  
> "query\_string": {  
> "query": "email",  
> "analyzer": "default\_search",  
> "fields": [  
> "file"  
> ]  
> }  
> }  
> }
> 
> however pulls up all results that match "email". I notice that if we  
> query on pre-defined stopwords such as "by" the query returns no results.
> 
> Am I doing something wrong in my stopwords definition that would cause my  
> custom list to be ignored and defaults to be used instead?
> 
> Thanks

---

<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:35am UTC](https://discuss.elastic.co/t/custom-stop-words-in-default-search/7006/3 "2017-07-06T03:35:54Z")

</div>


