from elasticsearch import Elasticsearch
from elasticsearch.helpers import bulk
es = Elasticsearch(hosts='localhost:9200')#创建索引表
es.indices.create(index='my', ignore=400)
插入一条数据到es的索引库中
data ={
"name":"小明","age":"8","gender":"男"}
res = es.index(index='my', doc_type='doc', body=data)