# External versioning when using nested documents and painless scripting

**URL:** <https://discuss.elastic.co/t/external-versioning-when-using-nested-documents-and-painless-scripting/322777>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [January 10, 2023, 1:19am UTC](https://discuss.elastic.co/t/external-versioning-when-using-nested-documents-and-painless-scripting/322777 "2023-01-10T01:19:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bpawQ](https://avatars.discourse-cdn.com/v4/letter/b/7ab992/32.png) [@bpawQ](https://discuss.elastic.co/u/bpawQ)\
**Post date:** [January 10, 2023, 1:19am UTC](https://discuss.elastic.co/t/external-versioning-when-using-nested-documents-and-painless-scripting/322777/1 "2023-01-10T01:19:27Z")

</div>

Hello, we have some use cases where we were considering using external versioning since we stream data from a DynamoDB instance to our elasticsearch cluster. I was wondering if it is possible to use external versioning in a bulk request where you send nested documents with painless scripting updates.

I have yet to verify any behavior related to painless scripting, however, in regards to the nested documents point it would seem that when i try to send a bulk request of the form

```auto
{ "index": {"_id" : "${id}", "_index" : "${this.getIndexName()}", "version": ${version}, "version_type": "external", "retry_on_conflict": ${retry_on_conflict} } }
{ "script": <painless script to run> }

```

example response

```auto
{"took":1,"errors":true,"items":[{"index":{"_index":"<index>","_type":"_doc","_id":"<parent_id>","status":409,"error":{"type":"version_conflict_engine_exception","reason":"[<parent_id>]: version conflict, current version [6] is higher or equal to the one provided [3]","index_uuid":"zfuN3XETQ46bIXEsQnI0Zw","shard":"0","index":"<index>"}}}]}

```

that i'll get a versioning error since it is looking up the parent document's version rather than applying this to the `version` field on the nested doc i want to add. I just wanted to double check if it is possible for external versioning to be used with nested documents before i rule this approach out?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 7, 2023, 1:19am UTC](https://discuss.elastic.co/t/external-versioning-when-using-nested-documents-and-painless-scripting/322777/2 "2023-02-07T01:19:37Z")

</div>

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