You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
559 B
20 lines
559 B
# 初始化ES连接
|
|
import urllib3
|
|
from elasticsearch import Elasticsearch
|
|
|
|
from Config import Config
|
|
|
|
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
|
|
|
# 初始化ES连接时添加verify_certs=False
|
|
es = Elasticsearch(
|
|
hosts=Config.ES_CONFIG['hosts'],
|
|
basic_auth=Config.ES_CONFIG['basic_auth'],
|
|
verify_certs=False # 禁用证书验证
|
|
)
|
|
|
|
# 查询所有index
|
|
indices = es.cat.indices(format='json')
|
|
print(f"当前ES集群中共有 {len(indices)} 个index:")
|
|
for idx in indices:
|
|
print(f"- {idx['index']}") |