在python中连接elasticsearch

原文地址:在python中连接elasticsearch -- 无敌牛

欢迎参观我的个人博客:无敌牛 -- 技术/著作/典籍/分享等

做一个记录,以后开发直接拷贝修改后使用即可。

代码如下

复制代码
# -*- coding:utf-8 -*-

from elasticsearch import Elasticsearch

ES_USER="user"
ES_PASSWORD="password"

es = Elasticsearch(
                ["https://127.0.0.1:9200"],
                basic_auth = (ES_USER, ES_PASSWORD),
                max_retries = 5,
                retry_on_timeout = True,
                retry_on_status=[502, 503, 504],
                verify_certs=False,
                connections_per_node = 8,
            )

if es.ping():
    print("=======================================")
else :
    print("error error error ")

indices = es.cat.indices(format="json", h=['index'])                                     
print(indices)
相关推荐
小龙在山东31 分钟前
Python 包管理工具 uv
windows·python·uv
weixin_307779131 小时前
批量OCR的GitHub项目
python·github·ocr
孤狼warrior2 小时前
灰色预测模型
人工智能·python·算法·数学建模
神仙别闹2 小时前
基于Python实现LSTM对股票走势的预测
开发语言·python·lstm
机器学习之心2 小时前
小波增强型KAN网络 + SHAP可解释性分析(Pytorch实现)
人工智能·pytorch·python·kan网络
JavaEdge在掘金2 小时前
MySQL 8.0 的隐藏索引:索引管理的利器,还是性能陷阱?
python
站大爷IP3 小时前
Python办公自动化实战:手把手教你打造智能邮件发送工具
python
chao_7893 小时前
回溯题解——子集【LeetCode】二进制枚举法
开发语言·数据结构·python·算法·leetcode
zdw3 小时前
fit parse解析佳明.fit 运动数据,模仿zwift数据展示
python
剑桥折刀s4 小时前
Python打卡:Day46
python