【发布时间】:2020-10-20 13:58:00
【问题描述】:
我已实施批量索引。我想让它更有效率。
# current implementation in Python
def products_to_index():
for product in all_products():
yield {
"_op_type": "index",
"_index": INDEX_NAME,
"_id": product.id,
"_source": {"name": product.name, "content": product.content},
}
def main(args):
# Connect to localhost:9200 by default.
es = Elasticsearch()
body = ANALYZER
es.indices.create(index=INDEX_NAME, body=body)
bulk(es, products_to_index())
此实现似乎只是获取所有数据并逐批索引它们。我想执行一个额外的步骤来检查这个条目是否已经被索引。
我还考虑过从本地保存的索引的path 加载。不知道如何继续。
我查看了 API 文档,但找不到任何内容。
【问题讨论】:
标签: python elasticsearch