# Reindex API changed \_version of docs

**URL:** <https://discuss.elastic.co/t/reindex-api-changed-version-of-docs/287305>\
**Category:** Elasticsearch\
**Created:** [October 21, 2021, 10:56am UTC](https://discuss.elastic.co/t/reindex-api-changed-version-of-docs/287305 "2021-10-21T10:56:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![d.silwon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/d.silwon/32/65853_2.png) [@d.silwon](https://discuss.elastic.co/u/d.silwon)\
**Post date:** [October 21, 2021, 10:56am UTC](https://discuss.elastic.co/t/reindex-api-changed-version-of-docs/287305/1 "2021-10-21T10:56:01Z")

</div>

Dears,

Why reindex API does not copy original doc \_version to new index?  
Is there any trick to force it?

query:

```auto
GET test/_search?version=true
{
"query": {
  "match_all": {}
  }
}

```

result:

```auto
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "test",
        "_type" : "_doc",
        "_id" : "2",
        "_version" : 1,
        "_score" : 1.0,
        "_source" : {
          "counter" : 1,
          "title" : "Allo",
          "tags" : [
            "green"
          ]
        }
      },
      {
        "_index" : "test",
        "_type" : "_doc",
        "_id" : "1",
        "_version" : 2,
        "_score" : 1.0,
        "_source" : {
          "counter" : 2,
          "title" : "Hey",
          "tags" : [
            "red"
          ]
        }
      }
    ]
  }
}

```

reidnex test index to new index test\_ds:

```auto
POST _reindex
{
  "source": {
    "index": "test"
  },
  "dest": {
    "index": "test_ds1"
  }
}

```

query new index:

```auto
POST _reindex
{
  "source": {
    "index": "test"
  },
  "dest": {
    "index": "test_ds1"
  }
}

```

and result:

```auto
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "test_ds1",
        "_type" : "_doc",
        "_id" : "2",
        "_version" : 1,
        "_score" : 1.0,
        "_source" : {
          "counter" : 1,
          "title" : "Allo",
          "tags" : [
            "green"
          ]
        }
      },
      {
        "_index" : "test_ds1",
        "_type" : "_doc",
        "_id" : "1",
        "_version" : 1,
        "_score" : 1.0,
        "_source" : {
          "counter" : 2,
          "title" : "Hey",
          "tags" : [
            "red"
          ]
        }
      }
    ]
  }
}

```

The \_version of docs was changed.

Best Regards,  
Dan

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [October 21, 2021, 11:12am UTC](https://discuss.elastic.co/t/reindex-api-changed-version-of-docs/287305/2 "2021-10-21T11:12:06Z")

</div>

I believe you can set `version_type: external` on the `dest` request. External isn't a great word for this, but it's the word you use when sending an index request. It says "I'm giving you the version, only perform the change if the index I give is more than your previous version".

---

<div class="post-metadata">

**Author:** ![d.silwon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/d.silwon/32/65853_2.png) [@d.silwon](https://discuss.elastic.co/u/d.silwon)\
**Post date:** [October 21, 2021, 11:19am UTC](https://discuss.elastic.co/t/reindex-api-changed-version-of-docs/287305/3 "2021-10-21T11:19:17Z")

</div>

> [@nik9000](#):
>
> version\_type: external

@nik9000  
It's working, thanks a lot.

Regards,  
Dan

---

<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:** [November 18, 2021, 11:19am UTC](https://discuss.elastic.co/t/reindex-api-changed-version-of-docs/287305/4 "2021-11-18T11:19:36Z")

</div>

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