Error when using colon (":") in elasticsearch query

Hey guys,

I don’t know nothing about Zammad code and Elasticsearch but there might be an issue with ES queries containing colon (":") characters. Everytime I try to use a colon in the search bar or in the customer field of the new ticket form, an exception will occur in Zammad production.log and elasticsearch.log. Maybe special strings/characters need to be escaped or encapsulated in a certain way?

Detailed error message:

E, [2018-09-12T15:44:57.874963 #50669] ERROR -- : Unable to process GET request to elasticsearch URL 'http://127.0.0.1:9200/zammad_production/Organization/_search'. Check the response and payload for detailed information:

Response:
#<UserAgent::Result:0x0000559ddbef1ef0 @success=false, @body="{\"error\":{\"root_cause\":[{\"type\":\"query_shard_exception\",\"reason\":\"Failed to parse query [::]\",\"index_uuid\":\"mukrkU8uQj-EMs7Y1ZZnGw\",\"index\":\"zammad_production\"}],\"type\":\"search_phase_execution_exception\",\"reason\":\"all shards failed\",\"phase\":\"query\",\"grouped\":true,\"failed_shards\":[{\"shard\":0,\"index\":\"zammad_production\",\"node\":\"xkhwOl5NScqYfKRfgQvrew\",\"reason\":{\"type\":\"query_shard_exception\",\"reason\":\"Failed to parse query [::]\",\"index_uuid\":\"mukrkU8uQj-EMs7Y1ZZnGw\",\"index\":\"zammad_production\",\"caused_by\":{\"type\":\"parse_exception\",\"reason\":\"Cannot parse '::': Encountered \\\" \\\":\\\" \\\": \\\"\\\" at line 1, column 0.\\nWas expecting one of:\\n    <NOT> ...\\n    \\\"+\\\" ...\\n    \\\"-\\\" ...\\n    <BAREOPER> ...\\n    \\\"(\\\" ...\\n    \\\"*\\\" ...\\n    <QUOTED> ...\\n    <TERM> ...\\n    <PREFIXTERM> ...\\n    <WILDTERM> ...\\n    <REGEXPTERM> ...\\n    \\\"[\\\" ...\\n    \\\"{\\\" ...\\n    <NUMBER> ...\\n    <TERM> ...\\n    \",\"caused_by\":{\"type\":\"parse_exception\",\"reason\":\"Encountered \\\" \\\":\\\" \\\": \\\"\\\" at line 1, column 0.\\nWas expecting one of:\\n    <NOT> ...\\n    \\\"+\\\" ...\\n    \\\"-\\\" ...\\n    <BAREOPER> ...\\n    \\\"(\\\" ...\\n    \\\"*\\\" ...\\n    <QUOTED> ...\\n    <TERM> ...\\n    <PREFIXTERM> ...\\n    <WILDTERM> ...\\n    <REGEXPTERM> ...\\n    \\\"[\\\" ...\\n    \\\"{\\\" ...\\n    <NUMBER> ...\\n    <TERM> ...\\n    \"}}}}]},\"status\":400}", @data=nil, @code="400", @content_type=nil, @error="Client Error: #<Net::HTTPBadRequest 400 Bad Request readbody=true>!">

Payload:
{"from"=>0, "size"=>10, "sort"=>[{:active=>{:order=>"desc"}}, {:updated_at=>{:order=>"desc"}}, "_score"], "query"=>{"bool"=>{"must"=>[{"query_string"=>{"query"=>"::", "default_operator"=>"AND"}}, {"query_string"=>{"query"=>"::", "default_operator"=>"AND"}}]}}}

Payload size: 0M
E, [2018-09-12T15:44:57.875071 #50669] ERROR -- : Unable to process GET request to elasticsearch URL 'http://127.0.0.1:9200/zammad_production/Organization/_search'. Check the response and payload for detailed information:

Response:
#<UserAgent::Result:0x0000559ddbef1ef0 @success=false, @body="{\"error\":{\"root_cause\":[{\"type\":\"query_shard_exception\",\"reason\":\"Failed to parse query [::]\",\"index_uuid\":\"mukrkU8uQj-EMs7Y1ZZnGw\",\"index\":\"zammad_production\"}],\"type\":\"search_phase_execution_exception\",\"reason\":\"all shards failed\",\"phase\":\"query\",\"grouped\":true,\"failed_shards\":[{\"shard\":0,\"index\":\"zammad_production\",\"node\":\"xkhwOl5NScqYfKRfgQvrew\",\"reason\":{\"type\":\"query_shard_exception\",\"reason\":\"Failed to parse query [::]\",\"index_uuid\":\"mukrkU8uQj-EMs7Y1ZZnGw\",\"index\":\"zammad_production\",\"caused_by\":{\"type\":\"parse_exception\",\"reason\":\"Cannot parse '::': Encountered \\\" \\\":\\\" \\\": \\\"\\\" at line 1, column 0.\\nWas expecting one of:\\n    <NOT> ...\\n    \\\"+\\\" ...\\n    \\\"-\\\" ...\\n    <BAREOPER> ...\\n    \\\"(\\\" ...\\n    \\\"*\\\" ...\\n    <QUOTED> ...\\n    <TERM> ...\\n    <PREFIXTERM> ...\\n    <WILDTERM> ...\\n    <REGEXPTERM> ...\\n    \\\"[\\\" ...\\n    \\\"{\\\" ...\\n    <NUMBER> ...\\n    <TERM> ...\\n    \",\"caused_by\":{\"type\":\"parse_exception\",\"reason\":\"Encountered \\\" \\\":\\\" \\\": \\\"\\\" at line 1, column 0.\\nWas expecting one of:\\n    <NOT> ...\\n    \\\"+\\\" ...\\n    \\\"-\\\" ...\\n    <BAREOPER> ...\\n    \\\"(\\\" ...\\n    \\\"*\\\" ...\\n    <QUOTED> ...\\n    <TERM> ...\\n    <PREFIXTERM> ...\\n    <WILDTERM> ...\\n    <REGEXPTERM> ...\\n    \\\"[\\\" ...\\n    \\\"{\\\" ...\\n    <NUMBER> ...\\n    <TERM> ...\\n    \"}}}}]},\"status\":400}", @data=nil, @code="400", @content_type=nil, @error="Client Error: #<Net::HTTPBadRequest 400 Bad Request readbody=true>!">

Payload:
{"from"=>0, "size"=>10, "sort"=>[{:active=>{:order=>"desc"}}, {:updated_at=>{:order=>"desc"}}, "_score"], "query"=>{"bool"=>{"must"=>[{"query_string"=>{"query"=>"::", "default_operator"=>"AND"}}, {"query_string"=>{"query"=>"::", "default_operator"=>"AND"}}]}}}

Payload size: 0M

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