Elasticsearch Python 最小 index() / insert 示例

此最小示例将单个文档插入运行在 http://localhost:9200 的 Elasticsearch:

es.index(index=“test-index”, id=1, body={“test”: 123})

es_index_example.py
#!/usr/bin/env python3
from elasticsearch import Elasticsearch

es = Elasticsearch()
es.index(index="test-index", id=1, body={"test": 123})

Check out similar posts by category: Databases, ElasticSearch, Python