# Errors for \_update\_by\_query:

**URL:** <https://discuss.elastic.co/t/errors-for--update-by-query/65564>\
**Category:** Elasticsearch\
**Created:** [November 9, 2016, 10:22pm UTC](https://discuss.elastic.co/t/errors-for--update-by-query/65564 "2016-11-09T22:22:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![go2jun](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/go2jun/32/44837_2.png) [@go2jun](https://discuss.elastic.co/u/go2jun)\
**Post date:** [November 9, 2016, 10:22pm UTC](https://discuss.elastic.co/t/errors-for--update-by-query/65564/1 "2016-11-09T22:22:49Z")

</div>

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

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

```

1. But It shows me error:

```auto
{
   "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

```

---

<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:** [November 9, 2016, 10:42pm UTC](https://discuss.elastic.co/t/errors-for--update-by-query/65564/2 "2016-11-09T22:42:51Z")

</div>

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![go2jun](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/go2jun/32/44837_2.png) [@go2jun](https://discuss.elastic.co/u/go2jun)\
**Post date:** [November 10, 2016, 7:29pm UTC](https://discuss.elastic.co/t/errors-for--update-by-query/65564/3 "2016-11-10T19:29:02Z")

</div>

Thanks @nik9000, this works

---

<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:** [December 8, 2016, 7:29pm UTC](https://discuss.elastic.co/t/errors-for--update-by-query/65564/4 "2016-12-08T19:29:14Z")

</div>

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