浏览代码

Be explicit about the fact backslashes need to be escaped. (#22257)

Relates #22255
Adrien Grand 8 年之前
父节点
当前提交
b2e93d2870
共有 1 个文件被更改,包括 18 次插入1 次删除
  1. 18 1
      docs/reference/query-dsl/query-string-query.asciidoc

+ 18 - 1
docs/reference/query-dsl/query-string-query.asciidoc

@@ -197,7 +197,24 @@ GET /_search
 
 Another option is to provide the wildcard fields search in the query
 string itself (properly escaping the `*` sign), for example:
-`city.\*:something`.
+`city.\*:something`:
+
+[source,js]
+--------------------------------------------------
+GET /_search
+{
+    "query": {
+        "query_string" : {
+            "query" : "city.\\*:(this AND that OR thus)",
+            "use_dis_max" : true
+        }
+    }
+}
+--------------------------------------------------
+// CONSOLE
+
+NOTE: Since `\` (backslash) is a special character in json strings, it needs to
+be escaped, hence the two backslashes in the above `query_string`.
 
 When running the `query_string` query against multiple fields, the
 following additional parameters are allowed: