How to insert new or update old document using elasticsearch-py? How to insert new or update old document using elasticsearch-py? elasticsearch elasticsearch

How to insert new or update old document using elasticsearch-py?


You can include "doc" field in the body to update.

es = Elasticsearch()doc = NewsSerializer(news).dataes.update(index="news_index", doc_type='news', id=1, body={"doc": doc})


You can't use the update query with both doc and script params. You can do all the stuff in the script field using the params field in it.

You may find more information in this post:

Elastic Search Partial Update