Environmental Science
elasticsearch 5.5
JDK 1.8
windows 7
Why does split make a mistake?
GET /data/_search
{
"from": 0,
"size": 6,
"query": {
"function_score": {
"query": {
"bool": {
"must": [
{
"term": {
"bookId_no_analyzer_sore": "0788e462-21a1-4c31-91ce-7e0383310a1a"
}
}
]
}},
"script_score" : {
"script" : {
"lang": "painless",
"params": {
"a": "行动"
},
"inline": "def myText = doc['text_nlp_sore.keyword'].value;if(myText != null){return myText.split(params.a).length;}else{return -1;}"
}
}
}
},
"sort": [
{
"_score": {
"order": "desc"
}
},
{
"pageNo_int_sore": {
"order": "asc"
}
}
]
}
out error
{
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"return myText.split(params.a).length;}else{",
" ^---- HERE"
],
"script": "def myText = doc['text_nlp_sore.keyword'].value;if(myText != null){return myText.split(params.a).length;}else{return -1;}",
"lang": "painless"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "data",
"node": "Gmil1PRGR4KJ2EXW1vV2hg",
"reason": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"return myText.split(params.a).length;}else{",
" ^---- HERE"
],
"script": "def myText = doc['text_nlp_sore.keyword'].value;if(myText != null){return myText.split(params.a).length;}else{return -1;}",
"lang": "painless",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Unable to find dynamic method [split] with [1] arguments for class [java.lang.String]."
}
}
}
]
},
"status": 500
}