# Elastic UpdateByQuery with timestamp

**URL:** <https://discuss.elastic.co/t/elastic-updatebyquery-with-timestamp/157795>\
**Category:** Elasticsearch\
**Created:** [November 22, 2018, 3:40am UTC](https://discuss.elastic.co/t/elastic-updatebyquery-with-timestamp/157795 "2018-11-22T03:40:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaralErdene\_Tumursuh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maralerdene_tumursuh/32/73137_2.png) [@MaralErdene\_Tumursuh](https://discuss.elastic.co/u/MaralErdene_Tumursuh)\
**Post date:** [November 22, 2018, 3:40am UTC](https://discuss.elastic.co/t/elastic-updatebyquery-with-timestamp/157795/1 "2018-11-22T03:40:33Z")

</div>

Hi all,

I'm using UpdateByQuery from java api. Then i'm setting timestamp value to date field. But this error returned.  
ScriptException[compile error]; nested: IllegalArgumentException[invalid sequence of tokens near ['16'].]; nested: NotSerializableExceptionWrapper[no\_viable\_alt\_exception: null];

Here is my source.  
"ctx.\_source.action\_date = 2018-11-20 16:00:00.000;"

Here is part of error  
Caused By: java.lang.IllegalArgumentException: invalid sequence of tokens near ['16'].  
at org.elasticsearch.painless.PainlessScript$Script.compile(ctx.\_source.action\_date=2018-11-20 16:00:00.000;

Should i set timestamp format. And how ? Any recommendation ?  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![gbrown](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gbrown/32/34482_2.png) [@gbrown](https://discuss.elastic.co/u/gbrown)\
**Post date:** [November 22, 2018, 4:09am UTC](https://discuss.elastic.co/t/elastic-updatebyquery-with-timestamp/157795/2 "2018-11-22T04:09:19Z")

</div>

The date format isn't your issue in this case - the problem causing that exception is that your Painless has a syntax error. You'll need to wrap the the date in quotes:

```auto
"ctx._source.action_date = \"2018-11-20 16:00:00.000\";"

```

Now, I can't say for sure that you won't also run into an issue with the date formatting without seeing your mapping. However, if this date string is the same as the format originally used in the document, you should be fine.

---

<div class="post-metadata">

**Author:** ![MaralErdene\_Tumursuh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maralerdene_tumursuh/32/73137_2.png) [@MaralErdene\_Tumursuh](https://discuss.elastic.co/u/MaralErdene_Tumursuh)\
**Post date:** [November 26, 2018, 3:51am UTC](https://discuss.elastic.co/t/elastic-updatebyquery-with-timestamp/157795/3 "2018-11-26T03:51:43Z")

</div>

Thank you. It is solved my problem.

---

<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 24, 2018, 3:52am UTC](https://discuss.elastic.co/t/elastic-updatebyquery-with-timestamp/157795/4 "2018-12-24T03:52:01Z")

</div>

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