Query DSL 查询 DSL
Elasticsearch 提供了一个功能全面的查询 DSL,这个查询 DSL 采用 JSON 格式来定义查询条件。你可以把查询 DSL 理解为一个查询的 AST,并由下面 2 中子类组成:
子叶型
子叶查询可以在特定的字段中查找特定的值,这类的查询有诸如
match
查询,term
查询或着range
查询等。这类查询也支持嵌套查询混合型
这边翻译地有点拗口,推荐看原文混合型查询会包装多个子叶型查询或者其他混合型查询。这会使得子查询的查询条件被组合(比如bool
查询或者dis_max
查询)或者被反转(比如not
或者constant_score
查询)。
查询子句的行为会因为它们究竟是被用来 查询内容还是过滤内容 而各不相同。
Elasticsearch provides a full Query DSL based on JSON to define queries. Think of the Query DSL as an AST 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
,term
orrange
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
bool
ordis_max
query), or to alter their behaviour (such as thenot
orconstant_score
query).
Query clauses behave differently depending on whether they are used in query context or filter context.