> 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/indices-cha-xun.md).

# Indices 查询

> 注意：**在5.0.0中已弃用。**

用搜索 **\_index** 字段来代替

**Indices**查询是在搜索跨多个指标执行的情况下非常有用。 它允许指定索引名称的列表和内部查询，该内部查询仅对与该列表上的名称匹配的索引执行。 对于被搜索、但没有在名单上的条目相匹配其他指数，使用**no\_match\_query** 代为执行。

```
GET /_search
{
    "query": {
        "indices" : {
            "indices" : ["index1", "index2"],
            "query" : { "term" : { "tag" : "wow" } },
            "no_match_query" : { "term" : { "tag" : "kow" } }
        }
    }
}
```

可以使用**index**字段，以提供一个单一的索引。\
**no\_match\_query**的取值是“string”，可以为**none**（匹配任何文件），也可以为**all**（匹配所有）。 默认为**all**。\
**query**是强制性的，此外还有**indices**（或**index**）也是强制性。
