# Parse fail

**URL:** <https://discuss.elastic.co/t/parse-fail/25173>\
**Category:** Elasticsearch\
**Created:** [July 8, 2015, 5:52pm UTC](https://discuss.elastic.co/t/parse-fail/25173 "2015-07-08T17:52:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![aarongu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aarongu/32/3626_2.png) [@aarongu](https://discuss.elastic.co/u/aarongu)\
**Post date:** [July 8, 2015, 5:52pm UTC](https://discuss.elastic.co/t/parse-fail/25173/1 "2015-07-08T17:52:22Z")

</div>

Hey there!

I'm currently using elasticsearch with python with flask as my server and I have a basic search set up.

When I search random words, search seems to work, but when I search characters such as [,] , :, (, ) , etc , i get a very long error message about parse failing.

> elasticsearch.exceptions.RequestError: TransportError(400, 'SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[F4EgB9ltRNqVeSqpytCOIQ][logs-index2][0]: SearchParseException[[logs-index2][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"query\_string": {"query": "["}}}]]]; nested: QueryParsingException[[logs-index2] Failed to parse query []; nested: ParseException[Cannot parse '[': Encountered "" at line 1, column 1.\r\nWas expecting one of:\r\n \<RANGE\_QUOTED\> ...\r\n \<RANGE\_GOOP\> ...\r\n]; nested: ParseException[Encountered "" at line 1, column 1.\r\nWas expecting one of:\r\n \<RANGE\_QUOTED\> ...\r\n \<RANGE\_GOOP\> ...\r\n]; }{[F4EgB9ltRNqVeSqpytCOIQ][logs-index2][1]: SearchParseException[[logs-index2][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"query\_string": {"query": "["}}}]]]; nested: QueryParsingException[[logs-index2] Failed to parse query []; nested: ParseException[Cannot parse '[': Encountered "" at line 1, column 1.\r\nWas expecting one of:\r\n \<RANGE\_QUOTED\> ...\r\n \<RANGE\_GOOP\> ...\r\n]; nested: ParseException[Encountered "" at line 1, column 1.\r\nWas expecting one of:\r\n \<RANGE\_QUOTED\> ...\r\n \<RANGE\_GOOP\> ...\r\n]; }{[F4EgB9ltRNqVeSqpytCOIQ][logs-index2][2]: SearchParseException[[logs-index2][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"query\_string": {"query": "["}}}]]]; nested: QueryParsingException[[logs-index2] Failed to parse query []; nested: ParseException[Cannot parse '[': Encountered "" at line 1, column 1.\r\nWas expecting one of:\r\n \<RANGE\_QUOTED\> ...\r\n \<RANGE\_GOOP\> ...\r\n]; nested: ParseException[Encountered "" at line 1, column 1.\r\nWas expecting one of:\r\n \<RANGE\_QUOTED\> ...\r\n \<RANGE\_GOOP\> ...\r\n]; }{[F4EgB9ltRNqVeSqpytCOIQ][logs-index2][3]: SearchParseException[[logs-index2][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"query\_string": {"query": "["}}}]]]; nested: QueryParsingException[[logs-index2] Failed to parse query []; nested: ParseException[Cannot parse '[': Encountered "" at line 1, column 1.\r\nWas expecting one of:\r\n \<RANGE\_QUOTED\> ...\r\n \<RANGE\_GOOP\> ...\r\n]; nested: ParseException[Encountered "" at line 1, column 1.\r\nWas expecting one of:\r\n \<RANGE\_QUOTED\> ...\r\n \<RANGE\_GOOP\> ...\r\n]; }{[F4EgB9ltRNqVeSqpytCOIQ][logs-index2][4]: SearchParseException[[logs-index2][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query": {"query\_string": {"query": "["}}}]]]; nested: QueryParsingException[[logs-index2] Failed to parse query []; nested: ParseException[Cannot parse '[': Encountered "" at line 1, column 1.\r\nWas expecting one of:\r\n \<RANGE\_QUOTED\> ...\r\n \<RANGE\_GOOP\> ...\r\n]; nested: ParseException[Encountered "" at line 1, column 1.\r\nWas expecting one of:\r\n \<RANGE\_QUOTED\> ...\r\n \<RANGE\_GOOP\> ...\r\n]; }]')

When I search those characters with quotes: e.g. "[" , "]" , the search seems to work. I would guess it has something to do with the encoding of the string. I have tried encoding to utf-8 but that gives even more problems.

Any help would be appreciated!

-Aaron

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [July 8, 2015, 5:54pm UTC](https://discuss.elastic.co/t/parse-fail/25173/2 "2015-07-08T17:54:24Z")

</div>

Can you show the exact query exactly as it's being sent to Elasticsearch?

---

<div class="post-metadata">

**Author:** ![aarongu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aarongu/32/3626_2.png) [@aarongu](https://discuss.elastic.co/u/aarongu)\
**Post date:** [July 8, 2015, 5:56pm UTC](https://discuss.elastic.co/t/parse-fail/25173/3 "2015-07-08T17:56:40Z")

</div>

Excuse me for not posting that in original post.

![](https://us1.discourse-cdn.com/elastic/original/2X/5/5941d6a791961fe97438ef0270e108854276ae4d.PNG)

Also, when there is a in the middle of a query string, it produces same results.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 8, 2015, 6:15pm UTC](https://discuss.elastic.co/t/parse-fail/25173/4 "2015-07-08T18:15:25Z")

</div>

You should prefer `simple_query_string`

---

<div class="post-metadata">

**Author:** ![aarongu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aarongu/32/3626_2.png) [@aarongu](https://discuss.elastic.co/u/aarongu)\
**Post date:** [July 8, 2015, 6:21pm UTC](https://discuss.elastic.co/t/parse-fail/25173/5 "2015-07-08T18:21:28Z")

</div>

That did it! Thank you so much!

---

<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, 12:02am UTC](https://discuss.elastic.co/t/parse-fail/25173/6 "2017-07-06T00:02:46Z")

</div>


