From 66cf3d3220a070fc75f75be124c27813f5bf3cd6 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Fri, 6 Jan 2017 16:46:42 -0700 Subject: [PATCH] Document simple_query_string negation with default_operator of OR This can be confusing when unexpected. Resolves #4707 --- .../simple-query-string-query.asciidoc | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/reference/query-dsl/simple-query-string-query.asciidoc b/docs/reference/query-dsl/simple-query-string-query.asciidoc index c67ba5cd73e..7ef7ba60cc5 100644 --- a/docs/reference/query-dsl/simple-query-string-query.asciidoc +++ b/docs/reference/query-dsl/simple-query-string-query.asciidoc @@ -83,6 +83,30 @@ The `simple_query_string` supports the following special characters: In order to search for any of these special characters, they will need to be escaped with `\`. +Be aware that this syntax may have a different behavior depending on the +`default_operator` value. For example, consider the following query: + +[source,js] +-------------------------------------------------- +GET /_search +{ + "query": { + "simple_query_string" : { + "fields" : ["content"], + "query" : "foo bar -baz" + } + } +} +-------------------------------------------------- +// CONSOLE + +You may expect that documents containing only "foo" or "bar" will be returned, +as long as they do not contain "baz", however, due to the `default_operator` +being OR, this really means "match documents that contain "foo" or documents +that contain "bar", or documents that don't contain "baz". If this is unintended +then the query can be switched to `"foo bar +-baz"` which will not return +documents that contain "baz". + [float] ==== Default Field When not explicitly specifying the field to search on in the query