I honestly don't know who named it painless
, because it really isn't, and the documentation isn't accurate for sure.
First of all, the field I'm trying to compare to a date is mapped as date
.
The script itself looks something like this:
Date max = new Date(params.updated_at);
for (...) {
if (ctx._source.arr[i]['updated_at'].after(max)) {
max = ctx._source.arr[i]['updated_at'];
}
}
ctx._source.updated_at = max;
And the error I get is: "caused_by":{"type":"illegal_argument_exception","reason":"Unable to find dynamic method [after] with [1] arguments for class [java.lang.String]."
.
Now my question is: why on Earth would a field that is mapped as date
would be string
?
Reading the API (https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-api-reference.html) clearly says there's a Date
with an after
method.
So... Am I doing something completely wrong here, or what's the case? Also, if it's how it is... do I really have to parse the string back to date every single time? And if so how?