Hi,
I was trying to create an scripted field. Where I was implementing the following logic which is return true if IP is equal to Pi_IP.
''' if (doc['IP.kayword'].value == doc['Pi_IP.keyword'].value)
{
retrun "true";
}
else{
return "false";
} '''
Error message in preview
{
"root_cause": [
{
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"... '].value)\r\n{\r\n retrun "true";\r\n}\r\nelse{\r\n re ...",
" ^---- HERE"
],
"script": "if (doc['IP.kayword'].value == doc['Pi_IP.keyword'].value)\r\n{\r\n retrun "true";\r\n}\r\nelse{\r\n return "false";\r\n}",
"lang": "painless",
"position": {
"offset": 74,
"start": 49,
"end": 99
}
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "compare_pim_index",
"node": "cvHdUiDSQqGRGScirAwjwQ",
"reason": {
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"... '].value)\r\n{\r\n retrun "true";\r\n}\r\nelse{\r\n re ...",
" ^---- HERE"
],
"script": "if (doc['IP.kayword'].value == doc['Pi_IP.keyword'].value)\r\n{\r\n retrun "true";\r\n}\r\nelse{\r\n return "false";\r\n}",
"lang": "painless",
"position": {
"offset": 74,
"start": 49,
"end": 99
},
"caused_by": {
"type": "illegal_argument_exception",
"reason": "invalid sequence of tokens near ['"true"'].",
"caused_by": {
"type": "no_viable_alt_exception",
"reason": null
}
}
}
}
]
}
Here are the drop down that I chose: