Hi there,
i have created scripted field for one of my index and here is the script:
def path = doc['request_id.keyword'].value;
if (path != null) {
def first = path.indexOf("_");
def second = first + 1 + path.substring(first + 1).indexOf("_");
def last = path.lastIndexOf("_");
return path.substring(first + 1, second);
}
return "";
but when i go to discover and load data for last 2 hours, i receive some error. Here is the detail:
{
"took" : 4225,
"timed_out" : false,
"_shards" : {
"total" : 140,
"successful" : 139,
"skipped" : 120,
"failed" : 1,
"failures" : [
{
"shard" : 2,
"index" : "mashery-logs.2022.05.26",
"node" : "wWo9DjrGQJaqhX2ybntIxQ",
"reason" : {
"type" : "script_exception",
"reason" : "runtime error",
"script_stack" : [
"org.elasticsearch.index.fielddata.ScriptDocValues$Strings.get(ScriptDocValues.java:568)",
"org.elasticsearch.index.fielddata.ScriptDocValues$Strings.getValue(ScriptDocValues.java:584)",
"""path = doc['request_id.keyword'].value;
""",
" ^---- HERE"
],
"script" : "def path = doc['request_id.keyword'].value; ...",
"lang" : "painless",
"position" : {
"offset" : 36,
"start" : 4,
"end" : 47
},
"caused_by" : {
"type" : "illegal_state_exception",
"reason" : "A document doesn't have a value for a field! Use doc[<field>].size()==0 to check if a document is missing a field!"
}
}
}
]
},
can you help me to solve this problem?