Open Search _bulk update with script and upsert

116 Views Asked by At

I am facing a challenge with bulk upsert on the OpenSearch index.

Currently, I am using the below POST method to perform bulk updates

Amazon OpenSearch Service v1.3

Method: POST _bulk
Payload:
{ "update": { "_id": "test-1" } }
{ "doc": { "uuid": "test", "status": false, "timestamp": "2024-01-31T23:05:09.909525Z"}, "doc_as_upsert": true }

What am i looking for?

I want to optimise the above bulk upsert action to update the document only if the status field has changed. So the ask is that the timestamp should only change if the status changes.

I am aware that there are scripts which will allow conditional update on bulk endpoint. Do they work with upsert? If possible, please share a sample script to perform the conditional bulk upsert.

Dhanyawad!

0

There are 0 best solutions below