11 lines
242 B
Python
11 lines
242 B
Python
from elasticsearch import Elasticsearch
|
|
|
|
# 连接本地的 Elasticsearch 实例
|
|
es = Elasticsearch(["http://localhost:9200"])
|
|
|
|
# 检查连接是否成功
|
|
if es.ping():
|
|
print("连接成功!")
|
|
else:
|
|
print("连接失败!")
|