Custom sequence numbers for partial updates

Hi,

I'm reading about partial updates and found that we cannot use external version with partial updates. However, I see that ES has introduced seq_no and primary_term for concurrency control. I see that seq_no is automatically incremented with every change but I cannot set it myself. Is there a way to set custom value for seq_no and/or primary_term for partial updates?

Thanks,
Shreedhan

The update API supports if_seq_no and if_primary_term parameters for optimistic concurrency control. See https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html

Is. that what you are after?

Thanks for the reply Alexander. I have looked at the Update API which supports both if_seq_no and if_primary_term, however, it appears that Elasticsearch sets these values and as a user we don't have an option to update these values. For instance, let's say this is what I get for a GET request.

GET localhost:9200/test/test/abcd/
{
  "_index": "test",
  "_type": "test",
  "_id": "abcd",
  "_version": 50,
  "_seq_no": 10,
  "_primary_term": 1,
  "found": true,
  "_source": {
    ....
   }
}

For the update API, I have to set if_seq_no to 10 and _primary_term to 1, otherwise I get a version_conflict_engine_exception. Note that I'm using external_version too, which I cannot use for partial update.

However, I want to send my custom seq_no. Let's say I want both seq_no and version to be the same.

POST localhost:9200/test/test/abcd/_update?if_seq_no=50&if_primary_term=1
{
	"doc": {
		"name": "test"
	}
}

This request also fails with version_conflict_engine_exception. I was wondering if we can supply external version for seq_no and/or primary_term.

Thanks,
Shreedhan

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.