# Failed to parse query with escaped quotation mark

**URL:** <https://discuss.elastic.co/t/failed-to-parse-query-with-escaped-quotation-mark/13643>\
**Category:** Elasticsearch\
**Created:** [September 17, 2013, 10:47am UTC](https://discuss.elastic.co/t/failed-to-parse-query-with-escaped-quotation-mark/13643 "2013-09-17T10:47:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maya](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@Maya](https://discuss.elastic.co/u/Maya)\
**Post date:** [September 17, 2013, 10:47am UTC](https://discuss.elastic.co/t/failed-to-parse-query-with-escaped-quotation-mark/13643/1 "2013-09-17T10:47:14Z")

</div>

Hi,

I pass the following query with escaped quotation mark:  
{  
"from": 0,  
"size": 100,  
"query": {  
"query\_string": {  
"query":  
""[http://www.ynet.co.il/tags/jQuery16103187891168054193\_1379319901404\*](http://www.ynet.co.il/tags/jQuery16103187891168054193_1379319901404*)"\*  
?"",  
"fields": [  
"string.VersionId"  
]  
}  
},  
"fields": [  
"Id",  
"string.LocalPath",  
"string.VersionId",  
"dateTime.CollectionTime"  
]  
}

and I get the error as if the quotation mark is not escaped:  
Caused by: org.elasticsearch.index.query.QueryParsingException:  
[monitoredqueries] Failed to parse query  
["[http://www.ynet.co.il/tags/jQuery16103187891168054193\_1379319901404"?"](http://www.ynet.co.il/tags/jQuery16103187891168054193_1379319901404%22?%22)]  
at  
org.elasticsearch.index.query.QueryStringQueryParser.parse(QueryStringQueryParser.java:225)  
at  
org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:193)  
at  
org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:272)  
at  
org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:250)  
at  
org.elasticsearch.search.query.QueryParseElement.parse(QueryParseElement.java:33)  
at  
org.elasticsearch.search.SearchService.parseSource(SearchService.java:561)  
... 12 more  
Caused by: org.apache.lucene.queryparser.classic.ParseException: Cannot  
parse  
'"[http://www.ynet.co.il/tags/jQuery16103187891168054193\_1379319901404"?"](http://www.ynet.co.il/tags/jQuery16103187891168054193_1379319901404%22?%22)':  
Lexical error at line 1, column 72. Encountered: after : ""  
at  
org.apache.lucene.queryparser.classic.QueryParserBase.parse(QueryParserBase.java:131)  
at  
org.elasticsearch.index.query.QueryStringQueryParser.parse(QueryStringQueryParser.java:213)  
... 17 more

Is that a known bug?

Thanks.

--  
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:** [September 18, 2013, 9:19pm UTC](https://discuss.elastic.co/t/failed-to-parse-query-with-escaped-quotation-mark/13643/2 "2013-09-18T21:19:34Z")

</div>

Hey,

the query\_string query might not be the best solution for queries like  
this, as it is using the lucene query parser (which can easily fail). You  
should check out the query DSL a bit further and maybe go with a match  
query or a term query - this largely depends how you want to query and what  
you are expected and what kind of data you have indexed. Maybe you can  
elaborate on that.

--Alex

On Tue, Sep 17, 2013 at 12:47 PM, mayap [maya.pollack@gmail.com](mailto:maya.pollack@gmail.com) wrote:

> Hi,
> 
> I pass the following query with escaped quotation mark:  
> {  
> "from": 0,  
> "size": 100,  
> "query": {  
> "query\_string": {  
> "query": ""  
> [ynet - תגיות](http://www.ynet.co.il/tags/jQuery16103187891168054193_1379319901404*%5C)"\*  
> ?"",  
> "fields": [  
> "string.VersionId"  
> ]  
> }  
> },  
> "fields": [  
> "Id",  
> "string.LocalPath",  
> "string.VersionId",  
> "dateTime.CollectionTime"  
> ]  
> }
> 
> and I get the error as if the quotation mark is not escaped:  
> Caused by: org.elasticsearch.index.query.QueryParsingException:  
> [monitoredqueries] Failed to parse query ["  
> [ynet - תגיות](http://www.ynet.co.il/tags/jQuery16103187891168054193_1379319901404%22?%22)]  
> at  
> org.elasticsearch.index.query.QueryStringQueryParser.parse(QueryStringQueryParser.java:225)  
> at  
> org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:193)  
> at  
> org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:272)  
> at  
> org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:250)  
> at  
> org.elasticsearch.search.query.QueryParseElement.parse(QueryParseElement.java:33)  
> at  
> org.elasticsearch.search.SearchService.parseSource(SearchService.java:561)  
> ... 12 more  
> Caused by: org.apache.lucene.queryparser.classic.ParseException: Cannot  
> parse '"  
> [ynet - תגיות](http://www.ynet.co.il/tags/jQuery16103187891168054193_1379319901404%22?%22)':  
> Lexical error at line 1, column 72. Encountered: after : ""  
> at  
> org.apache.lucene.queryparser.classic.QueryParserBase.parse(QueryParserBase.java:131)  
> at  
> org.elasticsearch.index.query.QueryStringQueryParser.parse(QueryStringQueryParser.java:213)  
> ... 17 more
> 
> Is that a known bug?
> 
> Thanks.
> 
> --  
> 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:** ![sina\_tamanna](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@sina\_tamanna](https://discuss.elastic.co/u/sina_tamanna)\
**Post date:** [September 19, 2013, 7:04am UTC](https://discuss.elastic.co/t/failed-to-parse-query-with-escaped-quotation-mark/13643/3 "2013-09-19T07:04:52Z")

</div>

Your quotation marks are unbalanced. You have one escaped quotation mark on  
the left and two escaped on the right.

--  
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:15am UTC](https://discuss.elastic.co/t/failed-to-parse-query-with-escaped-quotation-mark/13643/4 "2017-07-06T02:15:35Z")

</div>


