|
@@ -1,6 +1,6 @@
|
|
|
[[query-string-syntax]]
|
|
|
|
|
|
-==== Query string syntax
|
|
|
+=== Query string syntax
|
|
|
|
|
|
The query string ``mini-language'' is used by the
|
|
|
<<query-dsl-query-string-query>> and by the
|
|
@@ -14,7 +14,7 @@ phrase, in the same order.
|
|
|
Operators allow you to customize the search -- the available options are
|
|
|
explained below.
|
|
|
|
|
|
-===== Field names
|
|
|
+==== Field names
|
|
|
|
|
|
As mentioned in <<query-dsl-query-string-query>>, the `default_field` is searched for the
|
|
|
search terms, but it is possible to specify other fields in the query syntax:
|
|
@@ -46,7 +46,7 @@ search terms, but it is possible to specify other fields in the query syntax:
|
|
|
|
|
|
_exists_:title
|
|
|
|
|
|
-===== Wildcards
|
|
|
+==== Wildcards
|
|
|
|
|
|
Wildcard searches can be run on individual terms, using `?` to replace
|
|
|
a single character, and `*` to replace zero or more characters:
|
|
@@ -72,7 +72,7 @@ is missing some of its letters. However, by setting `analyze_wildcard` to
|
|
|
`true`, an attempt will be made to analyze wildcarded words before searching
|
|
|
the term list for matching terms.
|
|
|
|
|
|
-===== Regular expressions
|
|
|
+==== Regular expressions
|
|
|
|
|
|
Regular expression patterns can be embedded in the query string by
|
|
|
wrapping them in forward-slashes (`"/"`):
|
|
@@ -92,7 +92,7 @@ Elasticsearch to visit every term in the index:
|
|
|
Use with caution!
|
|
|
======
|
|
|
|
|
|
-===== Fuzziness
|
|
|
+==== Fuzziness
|
|
|
|
|
|
We can search for terms that are
|
|
|
similar to, but not exactly like our search terms, using the ``fuzzy''
|
|
@@ -112,7 +112,7 @@ sufficient to catch 80% of all human misspellings. It can be specified as:
|
|
|
|
|
|
quikc~1
|
|
|
|
|
|
-===== Proximity searches
|
|
|
+==== Proximity searches
|
|
|
|
|
|
While a phrase query (eg `"john smith"`) expects all of the terms in exactly
|
|
|
the same order, a proximity query allows the specified words to be further
|
|
@@ -127,7 +127,7 @@ query string, the more relevant that document is considered to be. When
|
|
|
compared to the above example query, the phrase `"quick fox"` would be
|
|
|
considered more relevant than `"quick brown fox"`.
|
|
|
|
|
|
-===== Ranges
|
|
|
+==== Ranges
|
|
|
|
|
|
Ranges can be specified for date, numeric or string fields. Inclusive ranges
|
|
|
are specified with square brackets `[min TO max]` and exclusive ranges with
|
|
@@ -178,10 +178,10 @@ would need to join two clauses with an `AND` operator:
|
|
|
===================================================================
|
|
|
|
|
|
The parsing of ranges in query strings can be complex and error prone. It is
|
|
|
-much more reliable to use an explicit <<query-dsl-range-filter,`range` filter>>.
|
|
|
+much more reliable to use an explicit <<query-dsl-range-query,`range` query>>.
|
|
|
|
|
|
|
|
|
-===== Boosting
|
|
|
+==== Boosting
|
|
|
|
|
|
Use the _boost_ operator `^` to make one term more relevant than another.
|
|
|
For instance, if we want to find all documents about foxes, but we are
|
|
@@ -196,7 +196,7 @@ Boosts can also be applied to phrases or to groups:
|
|
|
|
|
|
"john smith"^2 (foo bar)^4
|
|
|
|
|
|
-===== Boolean operators
|
|
|
+==== Boolean operators
|
|
|
|
|
|
By default, all terms are optional, as long as one term matches. A search
|
|
|
for `foo bar baz` will find any document that contains one or more of
|
|
@@ -256,7 +256,7 @@ would look like this:
|
|
|
|
|
|
****
|
|
|
|
|
|
-===== Grouping
|
|
|
+==== Grouping
|
|
|
|
|
|
Multiple terms or clauses can be grouped together with parentheses, to form
|
|
|
sub-queries:
|
|
@@ -268,7 +268,7 @@ of a sub-query:
|
|
|
|
|
|
status:(active OR pending) title:(full text search)^2
|
|
|
|
|
|
-===== Reserved characters
|
|
|
+==== Reserved characters
|
|
|
|
|
|
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
|
|
@@ -290,7 +290,7 @@ index is actually `"wifi"`. Escaping the space will protect it from
|
|
|
being touched by the query string parser: `"wi\ fi"`.
|
|
|
****
|
|
|
|
|
|
-===== Empty Query
|
|
|
+==== Empty Query
|
|
|
|
|
|
If the query string is empty or only contains whitespaces the query will
|
|
|
yield an empty result set.
|