python 往ES中简单插入数据

# -*- coding: utf-8 -*-
from elasticsearch import Elasticsearch

es = Elasticsearch(hosts="10.109.24.153", port=9200)
es.indices.create(index="cggg", ignore=400)

data = {"name": "小明", "age": "8", "gender": "男"}
res = es.index(index="cggg", doc_type="doc", body=data)
print(res)

猜你喜欢

转载自blog.csdn.net/Rouckie/article/details/87977595