# Stop words and query\_string

**URL:** <https://discuss.elastic.co/t/stop-words-and-query-string/11610>\
**Category:** Elasticsearch\
**Created:** [April 17, 2013, 9:04am UTC](https://discuss.elastic.co/t/stop-words-and-query-string/11610 "2013-04-17T09:04:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Johnny\_Mariethoz](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@Johnny\_Mariethoz](https://discuss.elastic.co/u/Johnny_Mariethoz)\
**Post date:** [April 17, 2013, 9:04am UTC](https://discuss.elastic.co/t/stop-words-and-query-string/11610/1 "2013-04-17T09:04:04Z")

</div>

Dear all,

as this is my first post, I want to thanks all elasticsearch contributors  
for this very nice tool.

However, I do not understand which analyzer is it used during the query.

The stop words seems not removed from the query for "\_al" or for a list of  
specified fields. Here is my test queries:

#!/bin/bash

#create index with specific stop words  
curl -XPOST -d '{  
"index": {  
"number\_of\_shards" : 3,  
"analysis": {  
"analyzer": {  
"english" : {  
"type":"english",  
"stopwords" : ["the", "stop1"]  
}  
}  
}  
}  
}' [http://localhost:9200/qstring](http://localhost:9200/qstring)  
echo

#apply analyzer  
curl -XPUT -d '{  
"doc" : {  
"properties" : {  
"text" : {  
"type" : "string",  
"analyzer" : "english"  
}  
}  
}  
}' [http://localhost:9200/qstring/doc/\_mapping](http://localhost:9200/qstring/doc/_mapping)  
echo

#sample data  
curl -XPOST -d '{  
"text" : "This is a test sentence containig stop words."  
}' [http://localhost:9200/qstring/doc?pretty=true](http://localhost:9200/qstring/doc?pretty=true)  
echo

#refresh for direct query  
curl -XPOST [http://localhost:9200/qstring/\_refresh](http://localhost:9200/qstring/_refresh)  
echo

#this query match as expected  
curl -d '{  
"query" : {  
"query\_string" : {  
"query" : "stop1 test",  
"default\_field": "text",  
"default\_operator": "AND"  
}  
}  
}' [http://localhost:9200/qstring/\_search?pretty=true](http://localhost:9200/qstring/_search?pretty=true)  
echo

#this does not match but why? Is it a bug?  
curl -d '{  
"query" : {  
"query\_string" : {  
"query" : "stop1 test",  
"default\_operator": "AND"  
}  
}  
}' [http://localhost:9200/qstring/\_search?pretty=true](http://localhost:9200/qstring/_search?pretty=true)  
echo

Do I miss something?

Many thanks in advance,

Regards,

-- Johnny

--  
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:** ![Johnny\_Mariethoz](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@Johnny\_Mariethoz](https://discuss.elastic.co/u/Johnny_Mariethoz)\
**Post date:** [April 22, 2013, 5:47am UTC](https://discuss.elastic.co/t/stop-words-and-query-string/11610/2 "2013-04-22T05:47:46Z")

</div>

Hello,

nobody really?

Regards,

-- Johnny

On Wednesday, April 17, 2013 11:04:04 AM UTC+2, Johnny Mariéthoz wrote:

> Dear all,
> 
> as this is my first post, I want to thanks all elasticsearch contributors  
> for this very nice tool.
> 
> However, I do not understand which analyzer is it used during the query.
> 
> The stop words seems not removed from the query for "\_al" or for a list of  
> specified fields. Here is my test queries:
> 
> #!/bin/bash
> 
> #create index with specific stop words  
> curl -XPOST -d '{  
> "index": {  
> "number\_of\_shards" : 3,  
> "analysis": {  
> "analyzer": {  
> "english" : {  
> "type":"english",  
> "stopwords" : ["the", "stop1"]  
> }  
> }  
> }  
> }  
> }' [http://localhost:9200/qstring](http://localhost:9200/qstring)  
> echo
> 
> #apply analyzer  
> curl -XPUT -d '{  
> "doc" : {  
> "properties" : {  
> "text" : {  
> "type" : "string",  
> "analyzer" : "english"  
> }  
> }  
> }  
> }' [http://localhost:9200/qstring/doc/\_mapping](http://localhost:9200/qstring/doc/_mapping)  
> echo
> 
> #sample data  
> curl -XPOST -d '{  
> "text" : "This is a test sentence containig stop words."  
> }' [http://localhost:9200/qstring/doc?pretty=true](http://localhost:9200/qstring/doc?pretty=true)  
> echo
> 
> #refresh for direct query  
> curl -XPOST [http://localhost:9200/qstring/\_refresh](http://localhost:9200/qstring/_refresh)  
> echo
> 
> #this query match as expected  
> curl -d '{  
> "query" : {  
> "query\_string" : {  
> "query" : "stop1 test",  
> "default\_field": "text",  
> "default\_operator": "AND"  
> }  
> }  
> }' [http://localhost:9200/qstring/\_search?pretty=true](http://localhost:9200/qstring/_search?pretty=true)  
> echo
> 
> #this does not match but why? Is it a bug?  
> curl -d '{  
> "query" : {  
> "query\_string" : {  
> "query" : "stop1 test",  
> "default\_operator": "AND"  
> }  
> }  
> }' [http://localhost:9200/qstring/\_search?pretty=true](http://localhost:9200/qstring/_search?pretty=true)  
> echo
> 
> Do I miss something?
> 
> Many thanks in advance,
> 
> Regards,
> 
> -- Johnny

--  
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:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [April 22, 2013, 7:11am UTC](https://discuss.elastic.co/t/stop-words-and-query-string/11610/3 "2013-04-22T07:11:06Z")

</div>

Hey,

you need to set the analyzer for the \_all field as well.

--Alex

On Mon, Apr 22, 2013 at 7:47 AM, Johnny Mariéthoz [chezjohnny@gmail.com](mailto:chezjohnny@gmail.com)wrote:

> Hello,
> 
> nobody really?
> 
> Regards,
> 
> -- Johnny
> 
> On Wednesday, April 17, 2013 11:04:04 AM UTC+2, Johnny Mariéthoz wrote:
> 
> > Dear all,
> > 
> > as this is my first post, I want to thanks all elasticsearch contributors  
> > for this very nice tool.
> > 
> > However, I do not understand which analyzer is it used during the query.
> > 
> > The stop words seems not removed from the query for "\_al" or for a list  
> > of specified fields. Here is my test queries:
> > 
> > #!/bin/bash
> > 
> > #create index with specific stop words  
> > curl -XPOST -d '{  
> > "index": {  
> > "number\_of\_shards" : 3,  
> > "analysis": {  
> > "analyzer": {  
> > "english" : {  
> > "type":"english",  
> > "stopwords" : ["the", "stop1"]  
> > }  
> > }  
> > }  
> > }  
> > }' [http://localhost:9200/qstring](http://localhost:9200/qstring)  
> > echo
> > 
> > #apply analyzer  
> > curl -XPUT -d '{  
> > "doc" : {  
> > "properties" : {  
> > "text" : {  
> > "type" : "string",  
> > "analyzer" : "english"  
> > }  
> > }  
> > }  
> > }' [http://localhost:9200/qstring/\*\*doc/\_mapping](http://localhost:9200/qstring/**doc/_mapping)[http://localhost:9200/qstring/doc/\_mapping](http://localhost:9200/qstring/doc/_mapping)  
> > echo
> > 
> > #sample data  
> > curl -XPOST -d '{  
> > "text" : "This is a test sentence containig stop words."  
> > }' [http://localhost:9200/qstring/\*\*doc?pretty=true](http://localhost:9200/qstring/**doc?pretty=true)[http://localhost:9200/qstring/doc?pretty=true](http://localhost:9200/qstring/doc?pretty=true)  
> > echo
> > 
> > #refresh for direct query  
> > curl -XPOST [http://localhost:9200/qstring/\*\*\_refresh](http://localhost:9200/qstring/**_refresh)[http://localhost:9200/qstring/\_refresh](http://localhost:9200/qstring/_refresh)  
> > echo
> > 
> > #this query match as expected  
> > curl -d '{  
> > "query" : {  
> > "query\_string" : {  
> > "query" : "stop1 test",  
> > "default\_field": "text",  
> > "default\_operator": "AND"  
> > }  
> > }  
> > }' [http://localhost:9200/qstring/\*\*\_search?pretty=true](http://localhost:9200/qstring/**_search?pretty=true)[http://localhost:9200/qstring/\_search?pretty=true](http://localhost:9200/qstring/_search?pretty=true)  
> > echo
> > 
> > #this does not match but why? Is it a bug?  
> > curl -d '{  
> > "query" : {  
> > "query\_string" : {  
> > "query" : "stop1 test",  
> > "default\_operator": "AND"  
> > }  
> > }  
> > }' [http://localhost:9200/qstring/\*\*\_search?pretty=true](http://localhost:9200/qstring/**_search?pretty=true)[http://localhost:9200/qstring/\_search?pretty=true](http://localhost:9200/qstring/_search?pretty=true)  
> > echo
> > 
> > Do I miss something?
> > 
> > Many thanks in advance,
> > 
> > Regards,
> > 
> > -- Johnny
> 
> --  
> 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).

--  
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:** ![Johnny\_Mariethoz](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@Johnny\_Mariethoz](https://discuss.elastic.co/u/Johnny_Mariethoz)\
**Post date:** [April 22, 2013, 8:49am UTC](https://discuss.elastic.co/t/stop-words-and-query-string/11610/4 "2013-04-22T08:49:37Z")

</div>

Hello Alex,

Thanks for your answer.

I agree that it will work on this specific case, but in my final  
application, I will use more than one term (english, french, but also  
keywords, title, etc.). In such case, I want that for a "\_all" query the  
corresponding analyzer would be used for each term, such as  
(english\_analyzer for english term, title\_analyzer for title and so on). As  
I understood, "analyzer" property is an alias for index\_analyzer and  
search\_analyzer.

I hopped that querying \_all will use the correct analyzer for each term.  
Your proposition is equivalent to set a analyzer for the query, but I do  
not want to have only one analyzer for all the terms.

Regards,

On Monday, April 22, 2013 9:11:06 AM UTC+2, Alexander Reelsen wrote:

> Hey,
> 
> you need to set the analyzer for the \_all field as well.
> 
> --Alex

--  
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:40am UTC](https://discuss.elastic.co/t/stop-words-and-query-string/11610/5 "2017-07-06T02:40:13Z")

</div>


