当前位置:   article > 正文

es获得所有index和type_es 查询所有index

es 查询所有index

1.获得所有index

rest方式:

curl 'localhost:9200/_cat/indices?v'
  • 1

JAVA方式:

GetIndexResponse response = client.admin().indices().prepareGetIndex().execute().actionGet(); System.out.println(response.getIndices().length);
 String[] indices = response.getIndices();
  for(String indice : indices){ 
  System.out.println(indice); 
  }
  • 1
  • 2
  • 3
  • 4
  • 5

2.获得所有type

rest方式:

curl -XGET 'http://localhost:9200/_mapping?pretty=true'
  • 1

非格式化:

curl -s -XGET 'http://localhost:9200/_mapping'
  • 1

JAVA方式:

GetMappingsResponse res = null; 
try { 
	res = client.admin().indices().getMappings(new GetMappingsRequest().indices(indice)).get();
 } catch (InterruptedException e) { 
	 e.printStackTrace(); 
 } catch (ExecutionException e) {
 	 e.printStackTrace(); 
 }
 ImmutableOpenMap<String, MappingMetaData> mapping = res.mappings().get(indice); 
 for (ObjectObjectCursor<String, MappingMetaData> c : mapping) 
 { 
 	 System.out.println("type = "+c.key); 
 	 System.out.println("columns = "+c.value.source());
  }


  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

172.16.10.115
查看集群健康:
curl -XGET ‘http://172.16.10.115:9200/_cluster/health?pretty
查看分片
curl -XGET http://172.16.10.115:9200/_cat/shards
curl -s “http://172.16.10.115:9200/_cat/shards” | grep UNASSIGNED
curl ‘172.16.10.115:9200/_nodes/process?pretty’
curl -XPOST ‘172.16.10.115:9200/_cluster/reroute’ -d '{“commands” : [ {“allocate” : {“index” : “ucp_log”,“shard” : 1,“node” : “nZVZ0qk5S7Wf_D8VUaTD_g”,“allow_primary” : true}}]


ES6版本java api
https://segmentfault.com/a/1190000015220491

转载自:https://www.jianshu.com/p/2186fba4be0e

参考 : https://www.jianshu.com/p/20c817187aa4
  • 1
  • 2
  • 3
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/寸_铁/article/detail/858346
推荐阅读
相关标签
  

闽ICP备14008679号