Parse fail

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

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

Excuse me for not posting that in original post.

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

You should prefer simple_query_string

That did it! Thank you so much!