Bulk Partial Upsert in Elasticseach with python
As J. Ku answered, he has given the right answer but the code provided is incomplete. So posting the complete answer.
data = [{ "_op_type": 'update', "_index": 'my_index', "_type": 'my_type', "_id": 12345, "doc": {"newkey": 'newvalue'}, "doc_as_upsert":True}]helpers.bulk(es, data, index='my_index', doc_type='my_type')
I think you need to include the action as mentioned in the documentation and set upsert as true
data = [{ "_op_type": 'update', "_index": 'my_index', "_type": 'my_type', "_id": 12345, "doc": {"newkey": 'newvalue'}}]helpers.bulk(es, data, index='my_index', doc_type='my_type')