Query DSL
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 clauses:
- Leaf query clauses
- Leaf query clauses look for a particular value in a particular field, such as the
match,termorrangequeries. 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
boolordis_maxquery), or to alter their behaviour (such as theconstant_scorequery).
Query clauses behave differently depending on whether they are used in query context or filter context.
- 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:
-
Queries that have a high up-front cost:
-
fuzzyqueries (except onwildcardfields) -
regexpqueries (except onwildcardfields) -
prefixqueries (except onwildcardfields or those withoutindex_prefixes) -
wildcardqueries (except onwildcardfields) -
rangequeries ontextandkeywordfields
-
- Joining queries
- Queries on deprecated geo-shapes
-
Queries that may have a high per-document cost:
-
The execution of such queries can be prevented by setting the value of the search.allow_expensive_queries setting to false (defaults to true).
© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/7.17/query-dsl.html