from elasticsearch import Elasticsearch from elasticsearch.client import IndicesClient from elasticsearch.client import CatClient import json host = '192.168.15.168' es = Elasticsearch(hosts=host) print(es.ping()) index_cli = IndicesClient(es) # print(index_cli) cat_cli = CatClient(es) all_index = cat_cli.indices() # print(all_index) # get all index name index_list_source = all_index.split('\n')[:-1] index_list = [] for i in index_list_source: index = i.split()[2] index_list.append(index) # print(index_list) # get index mapping info for i in index_list: mapping_info = index_cli.get_mapping(index=i) mapping_info = json.dumps(mapping_info, indent=2, ensure_ascii=False) print('============') # print(i,mapping_info)
from elasticsearch import Elasticsearch from elasticsearch.client import IndicesClient from elasticsearch.client import CatClient import json host = '127.0.0.1:9200' es = Elasticsearch(hosts=host) index_cli = IndicesClient(es) cat_cli = CatClient(es) index_list = cat_cli.indices() print(index_list) result = index_cli.get_settings(index="test_index0") # result = json.dumps(result,indent=2) print(result)