Elasticsearch version conflict

I have updated document in the Elasticsearch. after update using, I am fetching the same document by using their ID. It is giving me following response:
{

"_index": "b123456",
"_type": "documents",
"_id": "bltde56dd11ba998bab",
"_version": 3,
"found": true,
"_source": {
"title": "index.json",
"url": "/index1",
"tags": ,
"created_at": "2018-06-19T05:02:38.174Z",
"updated_at": "2018-06-19T05:07:57.155Z",
"version": 1,
"fields": [{
"uid": "fname",
"value": "john"
},
{
"uid": "lname",
"value": "test"
}
],
"class": "first"
}
}

After I am using update_by_query to update document I am sending following request to update_by_query:

{
"script": {
"source": "ctx._source.title = params.title;ctx._source.url = params.url;ctx._source.created_at = params.created_at;ctx._source.updated_at = params.updated_at;ctx._source.version = params.version;ctx._source.fields = params.fields",
"params": {
"title": "Demo title",
"url": "/demo",
"created_at": "2018-06-19T05:02:38.174Z",
"updated_at": "2018-06-19T05:07:57.155Z",
"version": 2,
"fields": [{
"uid": "fname",
"value": "vicky"
},
{
"uid": "lname",
"value": "test"
}
]
}
},
"query": {
"bool": {
"must": [{
"term": {
"_id": "bltde56dd11ba998bab"
}
},
{
"range": {
"version": {
"lt": 2
}
}
}
]
}
}
}

But it is giving me status code:409 and following error:

[documents][bltde56dd11ba998bab]: version conflict, current version [3] is different than the one provided [2]

My document also contains custom version key. Can anyone help me into this. How I solved this issue?

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