一. 环境准备:
Python 3.8
Elasticsearch 7.5
VirtaulBox 虚拟机客户端CentOs7
参考文档: https://elasticsearch-py.readthedocs.io/en/v7.12.1/transports.html
二. 连接Es
- 安装依赖包:
pip install elasticsearch
- 连接es 方法:
# -*- coding=utf8 -*-
from elasticsearch import Elasticsearch
import json
es = Elasticsearch(hosts="192.168.0.102", port=9200)