Reputation: 639
I'm trying to build a elasticsearch query string query. It is mentioned that reserved or special characters must to be escaped.
The reserved characters are: + - = && || > < ! ( ) { } [ ] ^ " ~ * ? : \ /
Failing to escape these special characters correctly could lead to a syntax error which prevents your query from running."
My question is: How can I escape the "special words" such "AND" or "OR". For example I would like to get the documents matching the text "NOW OR NEVER" (on all/any field) and that have status "active" OR "pending". The query below doesn't seem to work(OR is not escaped by elasticsearch).
NOW \OR NEVER status:(active OR pending)
Upvotes: 2
Views: 1252
Reputation: 141
You can try wrapping your text in double-quotes:
GET your_index/_search?q=status:(active OR pending) AND "NOW OR NEVER"
Upvotes: 2