def _index_chunk(chunk, doc_type, index):
"""
Add/update a list of records in Elasticsearch
Args:
chunk (list):
List of serialized items to index
doc_type (str):
The doc type for each item
index (str): An Elasticsearch index
Returns:
int: Number of items inserted into Elasticsearch
"""
conn = get_conn(verify_index=index)
insert_count, errors = bulk(
conn,
chunk,
index=index,
doc_type=doc_type,
)
if len(errors) > 0:
raise ReindexException("Error during bulk insert: {errors}".format(
errors=errors
))
refresh_index(index)
return insert_count
评论列表
文章目录