Hi Everyone,
I have recently upgraded from es 5.6 to es 8.10.
Following script field is working fine in es5.6
"script_fields": {
"customDate": {
"script": {
"inline": "def i ; if(params._source.customDate == null && params._source.remainder != null ) {
def cd = params._source.exDate;
def df = DateTimeFormatter.ofPattern(\"MM/dd/yyyy\");
def localDate = LocalDate.parse(cd,df);
if(doc['remainderType'].value=='day') { i = localDate.minusDays(doc['remainder'].value); }
else if(doc['remainderType'].value=='month') { i = localDate.minusMonths(doc['remainder'].value); }
else if(doc['remainderType'].value=='year') { i = localDate.minusYears(doc['remainder'].value); }
}
else if(params._source.customDate != null) {
i = params._source.customDate
}
return i"
}
}
}
field mapping:
"customDate": {
"type": "date",
"format": "MM/dd/yyyy"
},
"remainder": {
"type": "long"
},
"exDate": {
"type": "date",
"format": "MM/dd/yyyy",
"fields": {
"keyword": {
"type": "keyword"
}
}
}
"remainderType": {
"type": "keyword"
}
In es 8.10, it gives following error (response from kibana dev console):
#! [script][88:20] Deprecated field [inline] used, expected [source] instead
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "can not write type [class java.time.LocalDate]"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "index_v1",
"node": "node-A",
"reason": {
"type": "illegal_argument_exception",
"reason": "can not write type [class java.time.LocalDate]"
}
}
],
"caused_by": {
"type": "illegal_argument_exception",
"reason": "can not write type [class java.time.LocalDate]",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "can not write type [class java.time.LocalDate]"
}
}
},
"status": 400
}
Thanks in advance.