Python Forum

Full Version: bulk update in elasticsearch
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to update bulk document to elasticsearch

I am able to update this one by one document

following code works

  
elastic_output = Elasticsearch(output_master, http_auth=(elastic_user, elastic_password), port=9200)

 data_to_update = {
   "doc" : {
   "job": job_rec['job'],
   "site" : job_rec['site'],
   }
  }

elastic_output.update(index="my_index-2020",doc_type='_doc',id=data_to_update['doc']['job'],body=data_to_update)
how do I create bulk json and use bulk update?
I created list something like this by reading data from mongo.
where I am intested in updating record with new value called site


{'_op_type': 'update', '_index': 'my_index-2020', '_id': 314800814, 'doc_as_upsert': True, 'doc': {'job': 314800814, 'site': 'hill'}}
{'_op_type': 'update', '_index': 'my_index-2020', '_id': 314800815, 'doc_as_upsert': True, 'doc': {'job': 314800815, 'site': 'hill'}}

but can't figure out how do I use helper.