Reputation: 191
I am using POST /_search API to search data in elastic search 5.6.0.
When I tried to search for query Android 8.0 (Oreo) search API worked successfully, but when I tried for Android 8.0 (Oreo elastic search failed with error Failed to parse query [Android 8.0 (Oreo]
Please have a look at error below:
{
"shard":0,
"index":"my_index",
"node":"-Dzw5527SZGf7U0Ebut0PQ",
"reason":{
"type":"query_shard_exception",
"reason":"Failed to parse query [Android 8.0 (Oreo]",
"index_uuid":"wo7ihAX8Syy15MSDrS-Wsw",
"index":"my_index",
"caused_by":{
"type":"parse_exception",
"reason":"Cannot parse 'Android 8.0 (Oreo': Encountered \"<EOF>\" at line 1, column 17.\r\nWas expecting one of:\r\n <AND> ...\r\n <OR> ...\r\n <NOT> ...\r\n \"+\" ...\r\n \"-\" ...\r\n <BAREOPER> ...\r\n \"(\" ...\r\n \")\" ...\r\n \"*\" ...\r\n \"^\" ...\r\n <QUOTED> ...\r\n <TERM> ...\r\n <FUZZY_SLOP> ...\r\n <PREFIXTERM> ...\r\n <WILDTERM> ...\r\n <REGEXPTERM> ...\r\n \"[\" ...\r\n \"{\" ...\r\n <NUMBER> ...\r\n ",
"caused_by":{
"type":"parse_exception",
"reason":"Encountered \"<EOF>\" at line 1, column 17.\r\nWas expecting one of:\r\n <AND> ...\r\n <OR> ...\r\n <NOT> ...\r\n \"+\" ...\r\n \"-\" ...\r\n <BAREOPER> ...\r\n \"(\" ...\r\n \")\" ...\r\n \"*\" ...\r\n \"^\" ...\r\n <QUOTED> ...\r\n <TERM> ...\r\n <FUZZY_SLOP> ...\r\n <PREFIXTERM> ...\r\n <WILDTERM> ...\r\n <REGEXPTERM> ...\r\n \"[\" ...\r\n \"{\" ...\r\n <NUMBER> ...\r\n "
}
}
}
}
Below query worked for me :
{
"query":{
"bool":{
"must":[
{
"query_string":{
"query":"Android 8.0 (Oreo)",
"default_operator":"AND"
}
}
]
}
}
}
Below query throws an exception:
{
"query":{
"bool":{
"must":[
{
"query_string":{
"query":"Android 8.0 (Oreo",
"default_operator":"AND"
}
}
]
}
}
}
could you please help me on this, why am I getting an error when I missed ) in a query?
Upvotes: 0
Views: 5049
Reputation: 59
I also faced the same issue. String i was passing in the Postman was in wrong format. please check the format.
Upvotes: 0
Reputation: 217594
The parenthesis is a reserved character in the query string syntax, so you need to escape it like this
{
"query":{
"bool":{
"must":[
{
"query_string":{
"query":"Android 8.0 \\(Oreo",
"default_operator":"AND"
}
}
]
}
}
}
Upvotes: 3