我正在尝试定义以下平凡的脚本,但是在查询时却无法很好地编译
POST _scripts/calculate-score
{
"script": {
"lang": "painless",
"source": "ctx._score"
}
}
GET mygame/_search
{
"query": {
"script": {
"script": {
"id": "calculate-score",
"params": {
"my_modifier": 2
}
}
}
}
}
它返回:
{
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"ctx._score",
"^---- HERE"
],
"script": "ctx._score",
"lang": "painless"
}
我不知道实际上是怎么了。我什至尝试用数字替换ctx._score
,但没有任何变化。