Hi Everyone;
Here my painless script;
"script_fields": {
"seen": {
"script": {
"source": """
for (view in params['_source']['viewing_appointments']) {
if (new Date().getTime() - view.viewing_date.value.toInstant().toEpochMilli()) {
return true;
}
} return false;
"""
}
}
}
Please note that;
mapping type of "viewing_appointments" is NESTED
Since its type is nested, I have to access inner values of it by using "_source" method instead of "doc".
However; when I use "_source" method, Elasticsearch takes values at "JSON" format
and seems type of "viewing_date" as "String"
and throws error when I try to compare it with "Date".
How can I deal with this problem.
Thanks a lot ...