2013-08-28 19:24:34 -04:00
|
|
|
[[query-dsl]]
|
|
|
|
= Query DSL
|
|
|
|
|
|
|
|
[partintro]
|
|
|
|
--
|
|
|
|
|
2017-12-11 12:05:39 -05:00
|
|
|
Elasticsearch provides a full Query DSL (Domain Specific Language) based on JSON to define queries.
|
|
|
|
Think of the Query DSL as an AST (Abstract Syntax Tree) of queries, consisting of two types of
|
2015-06-03 19:59:22 -04:00
|
|
|
clauses:
|
|
|
|
|
|
|
|
Leaf query clauses::
|
|
|
|
|
|
|
|
Leaf query clauses look for a particular value in a particular field, such as the
|
|
|
|
<<query-dsl-match-query,`match`>>, <<query-dsl-term-query,`term`>> or
|
|
|
|
<<query-dsl-range-query,`range`>> queries. These queries can be used
|
|
|
|
by themselves.
|
|
|
|
|
|
|
|
Compound query clauses::
|
|
|
|
|
|
|
|
Compound query clauses wrap other leaf *or* compound queries and are used to combine
|
|
|
|
multiple queries in a logical fashion (such as the
|
|
|
|
<<query-dsl-bool-query,`bool`>> or <<query-dsl-dis-max-query,`dis_max`>> query),
|
2015-10-20 15:53:41 -04:00
|
|
|
or to alter their behaviour (such as the
|
2015-06-03 19:59:22 -04:00
|
|
|
<<query-dsl-constant-score-query,`constant_score`>> query).
|
|
|
|
|
|
|
|
Query clauses behave differently depending on whether they are used in
|
|
|
|
<<query-filter-context,query context or filter context>>.
|
2020-02-12 16:56:14 -05:00
|
|
|
|
|
|
|
[[query-dsl-allow-expensive-queries]]
|
|
|
|
Allow expensive queries::
|
|
|
|
Certain types of queries will generally execute slowly due to the way they are implemented, which can affect
|
|
|
|
the stability of the cluster. Those queries can be categorised as follows:
|
|
|
|
* Queries that need to do linear scans to identify matches:
|
|
|
|
** <<query-dsl-script-query, `script queries`>>
|
2020-07-28 12:12:33 -04:00
|
|
|
* Queries that have a high up-front cost :
|
|
|
|
** <<query-dsl-fuzzy-query,`fuzzy queries`>> (except on <<wildcard, `wildcard`>> fields)
|
|
|
|
** <<query-dsl-regexp-query,`regexp queries`>> (except on <<wildcard, `wildcard`>> fields)
|
|
|
|
** <<query-dsl-prefix-query,`prefix queries`>> (except on <<wildcard, `wildcard`>> fields or those without <<index-prefixes, `index_prefixes`>>)
|
|
|
|
** <<query-dsl-wildcard-query, `wildcard queries`>> (except on <<wildcard, `wildcard`>> fields)
|
2020-02-12 16:56:14 -05:00
|
|
|
** <<query-dsl-range-query, `range queries>> on <<text, `text`>> and <<keyword, `keyword`>> fields
|
|
|
|
* <<joining-queries, `Joining queries`>>
|
|
|
|
* Queries on <<prefix-trees, deprecated geo shapes>>
|
|
|
|
* Queries that may have a high per-document cost:
|
|
|
|
** <<query-dsl-script-score-query, `script score queries`>>
|
|
|
|
** <<query-dsl-percolate-query, `percolate queries`>>
|
|
|
|
|
|
|
|
The execution of such queries can be prevented by setting the value of the `search.allow_expensive_queries`
|
|
|
|
setting to `false` (defaults to `true`).
|
2013-08-28 19:24:34 -04:00
|
|
|
--
|
|
|
|
|
2015-06-03 19:59:22 -04:00
|
|
|
include::query-dsl/query_filter_context.asciidoc[]
|
|
|
|
|
2019-07-18 10:18:11 -04:00
|
|
|
include::query-dsl/compound-queries.asciidoc[]
|
2015-06-03 19:59:22 -04:00
|
|
|
|
|
|
|
include::query-dsl/full-text-queries.asciidoc[]
|
|
|
|
|
2019-07-18 10:18:11 -04:00
|
|
|
include::query-dsl/geo-queries.asciidoc[]
|
2015-06-03 19:59:22 -04:00
|
|
|
|
2019-08-14 17:35:10 -04:00
|
|
|
include::query-dsl/shape-queries.asciidoc[]
|
|
|
|
|
2015-06-03 19:59:22 -04:00
|
|
|
include::query-dsl/joining-queries.asciidoc[]
|
|
|
|
|
2019-07-18 10:18:11 -04:00
|
|
|
include::query-dsl/match-all-query.asciidoc[]
|
|
|
|
|
|
|
|
include::query-dsl/span-queries.asciidoc[]
|
2015-06-03 19:59:22 -04:00
|
|
|
|
|
|
|
include::query-dsl/special-queries.asciidoc[]
|
|
|
|
|
2019-07-18 10:18:11 -04:00
|
|
|
include::query-dsl/term-level-queries.asciidoc[]
|
2015-06-03 19:59:22 -04:00
|
|
|
|
|
|
|
include::query-dsl/minimum-should-match.asciidoc[]
|
|
|
|
|
2019-07-24 08:37:37 -04:00
|
|
|
include::query-dsl/multi-term-rewrite.asciidoc[]
|
|
|
|
|
2020-02-12 16:56:14 -05:00
|
|
|
include::query-dsl/regexp-syntax.asciidoc[]
|