from elasticsearch import Elasticsearch, RequestsHttpConnection
import certifi
es = Elasticsearch(
['<HOST>'],
http_auth=('username', 'password'),
port=9200,
use_ssl=False
)
res = es.index(index="my_index", doc_type="my_type", id=1, body={"title": "One", "tags": ["ruby"]})
print(res['created'])
res = es.get(index="my_index", doc_type="my_type", id=1)
print(res['_source'])
创建索引,参考
https://help.aliyun.com/document_detail/155919.html?spm=a2c4g.11186623.6.767.56c513e53sIJNr
https://help.aliyun.com/document_detail/134865.html?spm=a2c4g.11186623.6.577.4e923451ejx95q