环境: es版本8.2.2、 python3.6.9
pip3 install elasticsearch==7.13.4
pip3 install CMRESHandler==1.0.0踩坑 es8.0 弃用了_type, 所以需要指定 es_doc_type= None,并且调试的时候 raise_on_indexing_exceptions=True 否则看不到 CMRESHandler 报错信息
import logging
from cmreslogging.handlers import CMRESHandler
handler = CMRESHandler(hosts=[{'host': '192.168.6.103', 'port': 9200}],
auth_type=CMRESHandler.AuthType.BASIC_AUTH,
auth_details=("es_user", "es_password"),
es_index_name="hello",
es_doc_type=None,
raise_on_indexing_exceptions= True,)
log = logging.getLogger("PythonTest")
log.setLevel(logging.INFO)
log.addHandler(handler)
log.info("5555")
print("已发送1")
#
from elasticsearch import Elasticsearch
es = Elasticsearch([{"host": "192.168.6.103", "port": 9200}],
http_auth=("es_user", "es_password"))
es.index(index="hello", body={"msg": "6666"})
print("已发送2")
版权声明:本文为qq_40157234原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。