> For the complete documentation index, see [llms.txt](https://xiaoxiami.gitbook.io/elasticsearch/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xiaoxiami.gitbook.io/elasticsearch/ji-chu/35query-dsldslfang-shi-cha-8be229/355fu-he-cha-8be228-compound-queries.md).

# 3.5.5.复合查询(Compound queries)

复合查询用来包装其他复合或者叶子查询，一方面可综合其结果和分数，从而改变它的行为，另一方面可从查询切换到过滤器上下文。此类查询包含：

## [constant\_score 查询](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/query-dsl-constant-score-query.html)

这是一个包装其他查询的查询，并且在过滤器上下文中执行。与此查询匹配的所有文件都需要返回相同的“常量”***\_score***。

## [bool 查询](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/query-dsl-bool-query.html)

组合多个叶子并发查询或复合查询条件的默认查询类型，例如**must**,**should**,**must\_not**, 以及**filter**条件。 在**must**和**should**子句他们的分数相结合-匹配条件越多，预期越好-而**must\_not**和**filter**子句在过滤器上下文中执行。

## [dis\_max 查询](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/query-dsl-dis-max-query.html)

支持多并发查询的查询，并可返回与任意查询条件子句匹配的任何文档类型。与**bool**查询可以将所有匹配查询的分数相结合使用的方式不同的是，**dis\_max**查询只使用最佳匹配查询条件的分数。

## [function\_score 查询](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/query-dsl-function-score-query.html)

使用函数修改主查询返回的分数，以考虑诸如流行度，新近度，距离或使用脚本实现的自定义算法等因素。

## [boosting 查询](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/query-dsl-boosting-query.html)

返回匹配**positive**查询的文档，并且当减少文档的分数时其结果也匹配**negative**查询。

## [indices 查询](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/query-dsl-indices-query.html)

对指定的索引执行一个查询，对其他索引执行另一个查询。
