# Not able to copy from field data1 to field data2 in an existing index in ES

**URL:** <https://discuss.elastic.co/t/not-able-to-copy-from-field-data1-to-field-data2-in-an-existing-index-in-es/266224>\
**Category:** Elasticsearch\
**Created:** [March 4, 2021, 11:27am UTC](https://discuss.elastic.co/t/not-able-to-copy-from-field-data1-to-field-data2-in-an-existing-index-in-es/266224 "2021-03-04T11:27:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sandeep\_Raju](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@Sandeep\_Raju](https://discuss.elastic.co/u/Sandeep_Raju)\
**Post date:** [March 4, 2021, 11:27am UTC](https://discuss.elastic.co/t/not-able-to-copy-from-field-data1-to-field-data2-in-an-existing-index-in-es/266224/1 "2021-03-04T11:27:38Z")

</div>

Hi all,

I'm trying to copy data from field "updated" to "STATEMENT\_DATE".

```auto
POST /test_mycns_com/_update_by_query
{
  {
"query" : {
        "match_all" : {}
    }
  },
"script" : {
      "source": "ctx._source.STATEMENT_DATE = ctx._source.updated;",
      "lang": "painless"
  }
}

```

It gives the below error:

```auto
  "error": {
    "root_cause": [
      {
        "type": "json_parse_exception",
        "reason": "Unexpected character ('{' (code 123)): was expecting double-quote to start field name\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@57178133; line: 2, column: 4]"

```

I'm not able to figure where exactly I'm going wrong.

Need help.

Thanks in Advance

---

<div class="post-metadata">

**Author:** ![Sandeep\_Raju](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@Sandeep\_Raju](https://discuss.elastic.co/u/Sandeep_Raju)\
**Post date:** [March 4, 2021, 12:24pm UTC](https://discuss.elastic.co/t/not-able-to-copy-from-field-data1-to-field-data2-in-an-existing-index-in-es/266224/2 "2021-03-04T12:24:00Z")

</div>

Hi ,

SO basically i put query before script.

The correct way is to put script, then query:

```auto
  "script": {
    "source": "ctx._source.STATEMENT_DATE = ctx._source.updated",
    "lang": "painless"
  },
  "query": {
          "term": {
                  "species.keyword": "manage_apps"
          }
  }

```

---

<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:** [April 1, 2021, 12:24pm UTC](https://discuss.elastic.co/t/not-able-to-copy-from-field-data1-to-field-data2-in-an-existing-index-in-es/266224/3 "2021-04-01T12:24:34Z")

</div>

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