HI Team,
I'm working on scripted field to generate userid value in separate field and please find my error detail with script.
Script:
def m = /.*UserID/.matcher(doc['message.keyword'].value);
if ( m.matches() ) {
return m.group(1)
} else {
return "no match"
}
Message:
message.keyword: 2020-03-12 12:25:21:692 Logger - Received JSON Response: UserID: 124345
Error:
{
"root_cause": [
{
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:94)",
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:41)",
"m = /.*UserID/.matcher(doc['message.keyword'].value);\r\n",
" ^---- HERE"
],
"script": "def m = /.*UserID/.matcher(doc['message.keyword'].value);\r\nif ( m.matches() ) {\r\n return m.group(1)\r\n} else {\r\n return \"no match\"\r\n}",
"lang": "painless"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "test",
"node": "4QB1XVnuRzCkQ7KtGC4r9Q",
"reason": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:94)",
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:41)",
"m = /.*UserID/.matcher(doc['message.keyword'].value);\r\n",
" ^---- HERE"
],
"script": "def m = /.*UserID/.matcher(doc['message.keyword'].value);\r\nif ( m.matches() ) {\r\n return m.group(1)\r\n} else {\r\n return \"no match\"\r\n}",
"lang": "painless",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "No field found for [message.keyword] in mapping with types []"
}
}
}
]
}