Elastic UpdateByQuery with timestamp


(Maral Erdene Tumursuh) #1

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.


(Gordon Brown) #2

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:

"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.


(Maral Erdene Tumursuh) #3

Thank you. It is solved my problem.