# Simple Query String analyzer question

**URL:** <https://discuss.elastic.co/t/simple-query-string-analyzer-question/76273>\
**Category:** Elasticsearch\
**Created:** [February 23, 2017, 5:24pm UTC](https://discuss.elastic.co/t/simple-query-string-analyzer-question/76273 "2017-02-23T17:24:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![thiru](https://avatars.discourse-cdn.com/v4/letter/t/b9e5f3/32.png) [@thiru](https://discuss.elastic.co/u/thiru)\
**Post date:** [February 23, 2017, 5:24pm UTC](https://discuss.elastic.co/t/simple-query-string-analyzer-question/76273/1 "2017-02-23T17:24:29Z")

</div>

I have created the following index settings and mapping . I used the simple query string syntax for search .  
Do I need to explicitly specify my custom analyzer in the simple query search or it uses the required analyzer based on the mapping .

{  
"settings": {  
"analysis": {  
"analyzer": {  
"generic\_description\_analyzer": {  
"type": "custom",  
"tokenizer": "icu\_tokenizer",  
"filter": [  
"b\_synonym",  
"lowercase",  
"word\_split",  
"icu\_folding",  
"english\_stop",  
"char\_replace"  
]  
}  
},  
"filter": {  
"english\_stop": {  
"type": "stop",  
"stopwords": "_english_"  
},  
"word\_split": {  
"type": "word\_delimiter",  
"preserve\_original": 1  
},  
"char\_replace": {  
"type": "pattern\_replace",  
"pattern": "'",  
"replacement": ""  
},  
"b\_synonym": {  
"type": "synonym",  
"ignore\_case": true,  
"synonyms\_path": "analysis/brand\_synonym.txt"  
}  
}  
}  
},  
"mappings": {  
"brands": {  
"properties": {  
"brand": {  
"type": "text",  
"analyzer": "generic\_description\_analyzer"  
},  
"localbrand": {  
"type": "text",  
"analyzer": "generic\_description\_analyzer"  
},  
"globalbrandextension": {  
"type": "text",  
"analyzer": "generic\_description\_analyzer"  
},  
"productidentifier": {  
"type": "text",  
"analyzer": "generic\_description\_analyzer"  
},  
"category": {  
"type": "text",  
"analyzer": "generic\_description\_analyzer"  
}  
}  
}  
}  
}

**Query 1:**  
{  
"query": {  
"simple\_query\_string" : {  
"query": "+(|Foster's|Foster's Lager|Foster's Lager Beer)+",  
"fields": ["brand", "globalbrandextension", "localbrand", "productidentifier"],  
"default\_operator": "OR"

}  
}  
}

**Query 2**  
{  
"query": {  
"simple\_query\_string" : {  
"query": "+(|Foster's|Foster's Lager|Foster's Lager Beer)+",  
"fields": ["brand", "globalbrandextension", "localbrand", "productidentifier"],  
"default\_operator": "OR",  
"analyzer": "generic\_description\_analyzer"  
}  
}  
}

Which query is correct ?

Also how do I run analyze for the simple query string ?

I tried this Is this correct way of analyzing ? I want to see all the tokens.

**GET /indexname/\_analyze**  
{  
"field": "brand",  
"explain": true,  
"text": ["|Foster's|Foster's Lager|Foster's Lager Beer"]

}

---

<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:** [February 27, 2017, 8:52am UTC](https://discuss.elastic.co/t/simple-query-string-analyzer-question/76273/2 "2017-02-27T08:52:43Z")

</div>

Hey,

if you query more than one field, you have to test the API against all the fields. Using a dedicated analyzer in your query is not needed, if the analyzer is configured in the mapping already. The `_analyze` API always works against analyzers, if you want to check out, how your query was fired with all the fields involved, you can use the `explain` field in a search request to find out how the score was computed and how your query was depicted [https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-request-explain.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-request-explain.html)

Also, this might be interested for the analyze API [https://www.elastic.co/guide/en/elasticsearch/reference/5.2/\_explain\_analyze.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.2/_explain_analyze.html)

hope this helps!

--Alex

---

<div class="post-metadata">

**Author:** ![thiru](https://avatars.discourse-cdn.com/v4/letter/t/b9e5f3/32.png) [@thiru](https://discuss.elastic.co/u/thiru)\
**Post date:** [March 23, 2017, 3:57am UTC](https://discuss.elastic.co/t/simple-query-string-analyzer-question/76273/3 "2017-03-23T03:57:08Z")

</div>

Thanks for your reply

---

<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:** [April 20, 2017, 3:57am UTC](https://discuss.elastic.co/t/simple-query-string-analyzer-question/76273/4 "2017-04-20T03:57:14Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
