# Reindexing datetime field with an script expression

**URL:** <https://discuss.elastic.co/t/reindexing-datetime-field-with-an-script-expression/92410>\
**Category:** Elasticsearch\
**Created:** [July 10, 2017, 4:41am UTC](https://discuss.elastic.co/t/reindexing-datetime-field-with-an-script-expression/92410 "2017-07-10T04:41:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![enod](https://avatars.discourse-cdn.com/v4/letter/e/c77e96/32.png) [@enod](https://discuss.elastic.co/u/enod)\
**Post date:** [July 10, 2017, 4:41am UTC](https://discuss.elastic.co/t/reindexing-datetime-field-with-an-script-expression/92410/1 "2017-07-10T04:41:40Z")

</div>

Hi,

I'm not even sure whether it's possible or not. The problem is I didn't define the datetime format from the beginning and elasticsearch assumes it was in UTC and added 8 hours on every document. So I did following:

```
POST _reindex
{
  "source": {
    "index": "previous-index"
  },
  "dest": {
    "index": "new-index"
  },
    "script": {
    "lang": "expression",
    "inline": "ctx._source['datetime'] - multiplier",
    "params": {
      "multiplier": "8h"
    }
  }
}

```

Which gives me an following:  
{  
"error": {  
"root\_cause": [  
{  
"type": "unsupported\_operation\_exception",  
"reason": "scripts of type [inline], operation [update] and lang [expression] are not supported"  
}  
],  
"type": "unsupported\_operation\_exception",  
"reason": "scripts of type [inline], operation [update] and lang [expression] are not supported"  
},  
"status": 500  
}

Added following entry to elasticsearch.yml but no luck.  
`script.engine.groovy.inline.update: on`  
Any way to solve this issue? Thanks!

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [July 19, 2017, 6:46pm UTC](https://discuss.elastic.co/t/reindexing-datetime-field-with-an-script-expression/92410/2 "2017-07-19T18:46:46Z")

</div>

You are explicitly specifying an `expression` script (which is _not_ groovy, expression is its own language, from lucene). As the error message states, expressions cannot be used for update scripts (they are numeric only). If you are on 5.0+, you can try `painless`. Note that accessing the field from \_source you will get back a string (since this is how dates are serialized), so simply doing a subtraction like that will not. You will need to parse the date and then adjust it.

---

<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:** [August 16, 2017, 6:47pm UTC](https://discuss.elastic.co/t/reindexing-datetime-field-with-an-script-expression/92410/3 "2017-08-16T18:47:00Z")

</div>

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