Skip to content

Instantly share code, notes, and snippets.

@aplz
Created March 25, 2019 15:12
Show Gist options
  • Save aplz/62e52764bdcd0fb10ff5151f377c8e16 to your computer and use it in GitHub Desktop.
Save aplz/62e52764bdcd0fb10ff5151f377c8e16 to your computer and use it in GitHub Desktop.
elasticsearch - generator for bulk ingestion with upserts
for doc in collection:
yield {
'_id': id, '_type': TYPE,
'_index': index,
# with "doc_as_upsert": True, the document is either updated
# or created if it does not already exist.
'_op_type': 'update', 'doc': doc, "doc_as_upsert": True
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment