def delete_dataset(dataset_name):
"""Delete all entries from a particular dataset."""
q = {'query': {'term': {'dataset': dataset_name}}, '_source': False}
def deletes():
for i, res in enumerate(scan(es, query=q, index=es_index)):
yield {
'_op_type': 'delete',
'_index': str(es_index),
'_type': res.get('_type'),
'_id': res.get('_id')
}
if i > 0 and i % 10000 == 0:
log.info("Delete %s: %s", dataset_name, i)
es.indices.refresh(index=es_index)
bulk(es, deletes(), stats_only=True, chunk_size=DATA_PAGE)
optimize_search()
评论列表
文章目录