Errors for _update_by_query:

I have the following issue, could you tell me why? thanks

  1. Using Elasticsearch 2.3.3
  2. My index has two fields: _id(sting) and doc_id(Integer)
  3. I use this _update_by_query in Sense, I'm trying to copy all value _id to doc_id
POST /my_index/dataset/_update_by_query?conflicts=proceed
{
    "script": {
        "inline": "ctx.doc_id = ctx._id.toInteger()"
    }
}
  1. But It shows me error:
{
   "error": {
      "root_cause": [
         {
            "type": "illegal_argument_exception",
            "reason": "Invalid fields added to ctx [doc_id]"
         }
      ],
      "type": "illegal_argument_exception",
      "reason": "Invalid fields added to ctx [doc_id]"
   },
   "status": 400

doc_id isn't a thing you can edit. Do you want this:

POST /my_index/dataset/_update_by_query?conflicts=proceed
{
    "script": {
        "inline": "ctx._source.doc_id = ctx._id.toInteger()"
    }
}

btw, docID is the name of a concept in Lucene and it is fairly confusing to someone like me to have a field with a similar name.

1 Like

Thanks @nik9000, this works

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