# Stopword with Query\_string

**URL:** <https://discuss.elastic.co/t/stopword-with-query-string/8141>\
**Category:** Elasticsearch\
**Created:** [June 18, 2012, 8:40am UTC](https://discuss.elastic.co/t/stopword-with-query-string/8141 "2012-06-18T08:40:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vgross](https://avatars.discourse-cdn.com/v4/letter/v/ee59a6/32.png) [@vgross](https://discuss.elastic.co/u/vgross)\
**Post date:** [June 18, 2012, 8:40am UTC](https://discuss.elastic.co/t/stopword-with-query-string/8141/1 "2012-06-18T08:40:59Z")

</div>

Hi !

I have a problem with the stopword when I make a request of type  
"query\_string".

Here my index creation :

{  
"number\_of\_shards":5,  
"number\_of\_replicas":1,  
"analysis":{  
"analyzer":{  
"indexAnalyzerAc":{  
"type":"custom",  
"tokenizer":"whitespace",  
"filter":[

```
           "synonym",
           "lowercase",
           "asciifolding"
        ]
     },
     "searchAnalyzerAc":{
        "type":"custom",
        "tokenizer":"whitespace",
        "filter":[

           "synonym",
           "lowercase",
           "asciifolding"
        ]
     },
     "indexAnalyzerProd":{
        "type":"custom",
        "tokenizer":"whitespace",
        "filter":[

           "synonym",
           "lowercase",
           "asciifolding"
        ]
     },
     "searchAnalyzerProd":{
        "type":"custom",
        "tokenizer":"whitespace",
        "filter":[
           "synonym",
           "lowercase",
           "asciifolding",
                          "mystop"
        ]
     }
  },
  "filter":{
     "synonym":{
        "type":"synonym",
        "synonyms_path":"\/etc\/elasticsearch\/synonym.txt"
     },
     "mystop":{
        "type":"stop",
        "stopwords":[
           "_french_"
        ],
        "ignore_case":"true"
     }
  }

```

}  
}

And Here my Query :

{  
"query":{  
"query\_string":{  
"query":"robes en rouge",  
"default\_field":"\_all",  
"default\_operator":"and",  
"fields":[  
"\_all^1.0",  
"matiere^1",  
"tailles.nom1",  
"couleurs^1",  
"description^1",  
"ref\_mark^1",  
"libelle^1",  
"marque^1",  
"scat^2",  
"cat^3",  
"genre^1"  
]  
}  
}  
}

The problem is when I search "robes en rouge ", "en" being a stopword, if  
the filter is activated, the search returns any results to me, by cons, if  
the filter is disabled, I have 135 results.  
If I make the search "robes rouge" I have 175 results, the aim being to  
have the same number of result when searching "robe en rouge". But i have 0  
résult ☹

may be that the stop word filter is not activated with this type of request?

Can you help me ?

Thanks.

---

<div class="post-metadata">

**Author:** ![vgross](https://avatars.discourse-cdn.com/v4/letter/v/ee59a6/32.png) [@vgross](https://discuss.elastic.co/u/vgross)\
**Post date:** [June 19, 2012, 7:18am UTC](https://discuss.elastic.co/t/stopword-with-query-string/8141/2 "2012-06-19T07:18:51Z")

</div>

nobody can help me ? ☹

Le lundi 18 juin 2012 10:40:59 UTC+2, Vincent GROSS a écrit :

> Hi !
> 
> I have a problem with the stopword when I make a request of type  
> "query\_string".
> 
> Here my index creation :
> 
> {  
> "number\_of\_shards":5,  
> "number\_of\_replicas":1,  
> "analysis":{  
> "analyzer":{  
> "indexAnalyzerAc":{  
> "type":"custom",  
> "tokenizer":"whitespace",  
> "filter":[
> 
> ```
> "synonym",
> "lowercase",
> "asciifolding"
> ]
> },
> "searchAnalyzerAc":{
> "type":"custom",
> "tokenizer":"whitespace",
> "filter":[
> 
> "synonym",
> "lowercase",
> "asciifolding"
> ]
> },
> "indexAnalyzerProd":{
> "type":"custom",
> "tokenizer":"whitespace",
> "filter":[
> 
> "synonym",
> "lowercase",
> "asciifolding"
> ]
> },
> "searchAnalyzerProd":{
> "type":"custom",
> "tokenizer":"whitespace",
> "filter":[
> "synonym",
> "lowercase",
> "asciifolding",
> "mystop"
> ]
> }
> },
> "filter":{
> "synonym":{
> "type":"synonym",
> "synonyms_path":"\/etc\/elasticsearch\/synonym.txt"
> },
> "mystop":{
> "type":"stop",
> "stopwords":[
> "_french_"
> ],
> "ignore_case":"true"
> }
> }
> 
> ```
> 
> }  
> }
> 
> And Here my Query :
> 
> {  
> "query":{  
> "query\_string":{  
> "query":"robes en rouge",  
> "default\_field":"\_all",  
> "default\_operator":"and",  
> "fields":[  
> "\_all^1.0",  
> "matiere^1",  
> "tailles.nom1",  
> "couleurs^1",  
> "description^1",  
> "ref\_mark^1",  
> "libelle^1",  
> "marque^1",  
> "scat^2",  
> "cat^3",  
> "genre^1"  
> ]  
> }  
> }  
> }
> 
> The problem is when I search "robes en rouge ", "en" being a stopword, if  
> the filter is activated, the search returns any results to me, by cons, if  
> the filter is disabled, I have 135 results.  
> If I make the search "robes rouge" I have 175 results, the aim being to  
> have the same number of result when searching "robe en rouge". But i have 0  
> résult ☹
> 
> may be that the stop word filter is not activated with this type of  
> request?
> 
> Can you help me ?
> 
> Thanks.

---

<div class="post-metadata">

**Author:** ![vgross](https://avatars.discourse-cdn.com/v4/letter/v/ee59a6/32.png) [@vgross](https://discuss.elastic.co/u/vgross)\
**Post date:** [June 19, 2012, 12:50pm UTC](https://discuss.elastic.co/t/stopword-with-query-string/8141/3 "2012-06-19T12:50:18Z")

</div>

I just found the solution thanks to a french group of Elasticsearch!

In fact, if I explicitly set my analyzer when I make the request, good  
analyzer is considered and the application works.

It works for my request is as follows:

{  
"query":{  
"query\_string":{  
"query":"robes en rouge",  
"default\_field":"\_all",  
"default\_operator":"and",  
"analyzer" : "searchAnalyzerProd"  
"fields":[  
"\_all^1.0",  
"matiere^1",  
"tailles.nom1",  
"couleurs^1",  
"description^1",  
"ref\_mark^1",  
"libelle^1",  
"marque^1",  
"scat^2",  
"cat^3",  
"genre^1"  
]  
}  
}  
}

Thank to Benjamin Levient for his help !

Le lundi 18 juin 2012 10:40:59 UTC+2, Vincent GROSS a écrit :

> Hi !
> 
> I have a problem with the stopword when I make a request of type  
> "query\_string".
> 
> Here my index creation :
> 
> {  
> "number\_of\_shards":5,  
> "number\_of\_replicas":1,  
> "analysis":{  
> "analyzer":{  
> "indexAnalyzerAc":{  
> "type":"custom",  
> "tokenizer":"whitespace",  
> "filter":[
> 
> ```
> "synonym",
> "lowercase",
> "asciifolding"
> ]
> },
> "searchAnalyzerAc":{
> "type":"custom",
> "tokenizer":"whitespace",
> "filter":[
> 
> "synonym",
> "lowercase",
> "asciifolding"
> ]
> },
> "indexAnalyzerProd":{
> "type":"custom",
> "tokenizer":"whitespace",
> "filter":[
> 
> "synonym",
> "lowercase",
> "asciifolding"
> ]
> },
> "searchAnalyzerProd":{
> "type":"custom",
> "tokenizer":"whitespace",
> "filter":[
> "synonym",
> "lowercase",
> "asciifolding",
> "mystop"
> ]
> }
> },
> "filter":{
> "synonym":{
> "type":"synonym",
> "synonyms_path":"\/etc\/elasticsearch\/synonym.txt"
> },
> "mystop":{
> "type":"stop",
> "stopwords":[
> "_french_"
> ],
> "ignore_case":"true"
> }
> }
> 
> ```
> 
> }  
> }
> 
> And Here my Query :
> 
> {  
> "query":{  
> "query\_string":{  
> "query":"robes en rouge",  
> "default\_field":"\_all",  
> "default\_operator":"and",  
> "fields":[  
> "\_all^1.0",  
> "matiere^1",  
> "tailles.nom1",  
> "couleurs^1",  
> "description^1",  
> "ref\_mark^1",  
> "libelle^1",  
> "marque^1",  
> "scat^2",  
> "cat^3",  
> "genre^1"  
> ]  
> }  
> }  
> }
> 
> The problem is when I search "robes en rouge ", "en" being a stopword, if  
> the filter is activated, the search returns any results to me, by cons, if  
> the filter is disabled, I have 135 results.  
> If I make the search "robes rouge" I have 175 results, the aim being to  
> have the same number of result when searching "robe en rouge". But i have 0  
> résult ☹
> 
> may be that the stop word filter is not activated with this type of  
> request?
> 
> Can you help me ?
> 
> 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:23am UTC](https://discuss.elastic.co/t/stopword-with-query-string/8141/4 "2017-07-06T03:23:25Z")

</div>


