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

Hi all,

I'm trying to copy data from field "updated" to "STATEMENT_DATE".

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:

  "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

Hi ,

SO basically i put query before script.

The correct way is to put script, then query:

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

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