# Exact phrases in query\_string

**URL:** <https://discuss.elastic.co/t/exact-phrases-in-query-string/6506>\
**Category:** Elasticsearch\
**Created:** [January 25, 2012, 11:06pm UTC](https://discuss.elastic.co/t/exact-phrases-in-query-string/6506 "2012-01-25T23:06:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![searchersteve](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/searchersteve/32/3008_2.png) [@searchersteve](https://discuss.elastic.co/u/searchersteve)\
**Post date:** [January 25, 2012, 11:06pm UTC](https://discuss.elastic.co/t/exact-phrases-in-query-string/6506/1 "2012-01-25T23:06:10Z")

</div>

I am using the query\_string method and submitting a user's free-form query syntax, allowing for normal boolean phrasing as people are accustomed to using with Google etc. My understanding is that query\_string will parse such queries properly. Among the forms that I want it to parse is an exact phrase, assuming the user will indicate an exact phrase by using quotation marks. So, for example:

writers "Charles Dickens"

I have read the documentation on the query\_string method in the DSL, plus this [thread](http://elasticsearch-users.115913.n3.nabble.com/exact-phrase-search-query-failing-tt3258273.html#none). I am submitting the query with the quotation marks escaped:

"query\_string": "writers "Charles Dickens""

However, the ES parser seems to be splitting the terms into individual "OR" elements. I get records with "Charles" that are not "Charles Dickens". What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)\
**Post date:** [January 26, 2012, 12:47am UTC](https://discuss.elastic.co/t/exact-phrases-in-query-string/6506/2 "2012-01-26T00:47:26Z")

</div>

Hi,

it works for me. Trying ES 0.18.7 out of the box:

> <https://gist.github.com/lukas-vlcek/1680067>

Regards,  
Lukas

On Thu, Jan 26, 2012 at 12:06 AM, searchersteve [stevesuo@gmail.com](mailto:stevesuo@gmail.com) wrote:

> I want to run a query that return results for Robert E. Anderson and not  
> for  
> Robert Johnson.
> 
> I have read the documentation on the query\_string method in the DSL, plus  
> this
> 
> [http://elasticsearch-users.115913.n3.nabble.com/exact-phrase-search-query-failing-tt3258273.html#none](http://elasticsearch-users.115913.n3.nabble.com/exact-phrase-search-query-failing-tt3258273.html#none)  
> thread . I am submitting the query with the quotation marks escaped:
> 
> "query\_string": ""Robert E. Anderson""
> 
> However, the ES parser seems to be splitting the terms into individual "OR"  
> elements. I get records with "Robert" that are not "Robert E. Anderson".  
> What am I doing wrong?
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Exact-phrases-in-query-string-tp3689284p3689284.html](http://elasticsearch-users.115913.n3.nabble.com/Exact-phrases-in-query-string-tp3689284p3689284.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<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:41am UTC](https://discuss.elastic.co/t/exact-phrases-in-query-string/6506/3 "2017-07-06T03:41:26Z")

</div>


