# Copy data to new index and change data type

**URL:** <https://discuss.elastic.co/t/copy-data-to-new-index-and-change-data-type/195671>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [August 19, 2019, 5:16am UTC](https://discuss.elastic.co/t/copy-data-to-new-index-and-change-data-type/195671 "2019-08-19T05:16:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Koshur](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/koshur/32/52434_2.png) [@Koshur](https://discuss.elastic.co/u/Koshur)\
**Post date:** [August 19, 2019, 5:16am UTC](https://discuss.elastic.co/t/copy-data-to-new-index-and-change-data-type/195671/1 "2019-08-19T05:16:51Z")

</div>

I need to change data types of two of my fields.

1. From string to object
2. From Nested (array) to object.

I understand that this cannot be changed within the same index and I would have to use `_REINDEX`.

I am been trying to do this but been largely unsuccessfull.

Example:

Below are the current fields:

```
"role": "Full",
"access": [
            {
              "client": "Full"
            }
 ]

```

New fields:

```
"role": {
            "env1": "Full",
            "env2": "Full",
            "env3": "Full"
          },
"access": {
            "env1": [
              {
                "client": "Full"
              }
            ],
            "env2": [
              {
                "client": "Full"
              }
            ],
            "env3": [
              {
                "client": "Full"
              }
            ]
}

```

I understand that we use ingest node feature but it doesn't seem to work with objects. Please help?

---

<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:** [September 16, 2019, 5:16am UTC](https://discuss.elastic.co/t/copy-data-to-new-index-and-change-data-type/195671/2 "2019-09-16T05:16:51Z")

</div>

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