Skip to content

Commit 116165f

Browse files
committed
Clarifies how query_string splits textual part (#28798)
* Clarifies how the query_string splits textual part to build a query Whitespaces are not considered as operators anymore in 6x but the documentation is not clear about it. This commit changes the example in the documentation and adds a note regarding whitespaces and operators. Closes #28719
1 parent fb8025d commit 116165f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

docs/reference/query-dsl/query-string-query.asciidoc

+10-2
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,22 @@ GET /_search
2828
"query": {
2929
"query_string" : {
3030
"default_field" : "content",
31-
"query" : "field:new york AND city"
31+
"query" : "(new york city) OR (big apple)"
3232
}
3333
}
3434
}
3535
--------------------------------------------------
3636
// CONSOLE
3737

38-
... will be splitted in `new`, `york` and `city` and each part is analyzed independently.
38+
... will be split into `new york city` and `big apple` and each part is then
39+
analyzed independently by the analyzer configured for the field.
40+
41+
WARNING: Whitespaces are not considered operators, this means that `new york city`
42+
will be passed "as is" to the analyzer configured for the field. If the field is a `keyword`
43+
field the analyzer will create a single term `new york city` and the query builder will
44+
use this term in the query. If you want to query each term separately you need to add explicit
45+
operators around the terms (e.g. `new AND york AND city`).
46+
3947
When multiple fields are provided it is also possible to modify how the different
4048
field queries are combined inside each textual part using the `type` parameter.
4149
The possible modes are described <<multi-match-types, here>> and the default is `best_fields`.

0 commit comments

Comments
 (0)