多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# Cluster State 原文链接 : [https://www.elastic.co/guide/en/elasticsearch/reference/5.0/cluster-state.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/cluster-state.html) 译文链接 : [http://www.apache.wiki/display/Elasticsearch/Cluster+State](http://www.apache.wiki/display/Elasticsearch/Cluster+State) 贡献者 : [那伊抹微笑](/display/~wangyangting) **cluster state**(集群状态)**API** 可以获取一个整个集群更全面的状态。 ``` $ curl -XGET 'http://localhost:9200/_cluster/state' ``` 默认情况下,该集群状态的请求被路由到 **Master**(主)节点,以确保最近的集群状态可以被返回。出于调试的目的,您可以去指定的本地节点通过添加 **local=true** 到查询字符串中获取集群状态。 ## Response Filters(响应过滤) 由于集群状态可以增加(取决于分片和索引的数量,映射,模版),可能需要过滤集群状态的响应,在 **URL** 中指定部分参数。 ``` $ curl -XGET 'http://localhost:9200/_cluster/state/{metrics}/{indices}' ``` | 参数 | 描述 | | --- | --- | | metrics | can be a comma-separated list of | | version | Shows the cluster state version. | | master_node | Shows the elected `master_node` part of the response | | nodes | Shows the `nodes` part of the response | | routing_table | Shows the `routing_table` part of the response. If you supply a comma separated list of indices, the returned output will only contain the indices listed. | | metadata | Shows the `metadata` part of the response. If you supply a comma separated list of indices, the returned output will only contain the indices listed. | | blocks | Shows the `blocks` part of the response | 几个示例如下 :  ``` # return only metadata and routing_table data for specified indices $ curl -XGET 'http://localhost:9200/_cluster/state/metadata,routing_table/foo,bar' # return everything for these two indices $ curl -XGET 'http://localhost:9200/_cluster/state/_all/foo,bar' # Return only blocks data $ curl -XGET 'http://localhost:9200/_cluster/state/blocks' ```