|
@@ -271,12 +271,27 @@ of a sub-query:
|
|
|
If you need to use any of the characters which function as operators in your
|
|
|
query itself (and not as operators), then you should escape them with
|
|
|
a leading backslash. For instance, to search for `(1+1)=2`, you would
|
|
|
-need to write your query as `\(1\+1\)\=2`.
|
|
|
+need to write your query as `\(1\+1\)\=2`. When using JSON for the request body, two preceding backslashes (`\\`) are required; the backslash is a reserved escaping character in JSON strings.
|
|
|
+
|
|
|
+[source,console]
|
|
|
+----
|
|
|
+GET /twitter/_search
|
|
|
+Content-Type: application/json
|
|
|
+
|
|
|
+{
|
|
|
+ "query" : {
|
|
|
+ "query_string" : {
|
|
|
+ "query" : "kimchy\\!",
|
|
|
+ "fields" : ["user"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+----
|
|
|
+// TEST[setup:twitter]
|
|
|
|
|
|
The reserved characters are: `+ - = && || > < ! ( ) { } [ ] ^ " ~ * ? : \ /`
|
|
|
|
|
|
-Failing to escape these special characters correctly could lead to a syntax
|
|
|
-error which prevents your query from running.
|
|
|
+Failing to escape these special characters correctly could lead to a syntax error which prevents your query from running.
|
|
|
|
|
|
NOTE: `<` and `>` can't be escaped at all. The only way to prevent them from
|
|
|
attempting to create a range query is to remove them from the query string
|