Not able to query with reserved characters
See original GitHub issueI’m using the following query string.
query_string : {
fields : [“field1”, “field2”],
query : "*testing\(*"
}
But getting the following error:
“msg”: “[query_parsing_exception] Failed to parse query [testing(], with { index=someindex line=1 col=166 }”, “path”: “/somepath”, “query”: {}, “body”: “{"query":{"bool":{"must":[{"query_string":{"fields":["buildName","programName","sites","taskName","assignedTo","currentStatus","name","dueDate"],"query":"testing("}},{"missing":{"field":"deleted"}}],"must_not":{"match":{"currentStatus":"Completed"}}}},"from":0,"size":"10","sort":[{"dueDate":{"order":"asc"}}]}”, “statusCode”: 400, “response”: “{"error":{"root_cause":[{"type":"query_parsing_exception","reason":"Failed to parse query [testing(]","index":"someindex","line":1,"col":166}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"someindex","node":"0v5EQ99oRWeZfN0WIU59wA","reason":{"type":"query_parsing_exception","reason":"Failed to parse query [testing(]","index":"someindex","line":1,"col":166,"caused_by":{"type":"parse_exception","reason":"Cannot parse ‘testing(’: Encountered \"<EOF>\" at line 1, column 10.\nWas expecting one of:\n <AND> …\n <OR> …\n <NOT> …\n \"+\" …\n \"-\" …\n <BAREOPER> …\n \"(\" …\n \")\" …\n \"\" …\n \"^\" …\n <QUOTED> …\n <TERM> …\n <FUZZY_SLOP> …\n <PREFIXTERM> …\n <WILDTERM> …\n <REGEXPTERM> …\n \"[\" …\n \"{\" …\n <NUMBER> …\n ","caused_by":{"type":"parse_exception","reason":"Encountered \"<EOF>\" at line 1, column 10.\nWas expecting one of:\n <AND> …\n <OR> …\n <NOT> …\n \"+\" …\n \"-\" …\n <BAREOPER> …\n \"(\" …\n \")\" …\n \"\" …\n \"^\" …\n <QUOTED> …\n <TERM> …\n <FUZZY_SLOP> …\n <PREFIXTERM> …\n <WILDTERM> …\n <REGEXPTERM> …\n \"[\" …\n \"{\" …\n <NUMBER> …\n "}}}}]},"status":400}” }
I’ve used "" to escape the special character “(”. Can’t I use special characters with wildcards? Any suggestions?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
@kaustav1992 I just ran into this need and built this function to escape user-provided values going into
query_string
. I think it’s what you were asking for.Kibana should only be using the JSON search DSL when consuming user input.