ES Версия: number: "7.0.1",
Следующий запрос не работает. Возвращает illegal_argument_exception
(Полный стек ниже).
{
"query": {
"function_score": {
"query": {
"query_string": {
"query": "SOME_QUERY"
}
},
"script_score": {
"script": {
"source": "Math.log(doc['SOME_FIELD'].value + 1)"
}
}
}
}
}
Возможно, с doc['SOME_FIELD'].value
может быть какая-то проблема, но, очевидно, есть некоторые проблемы с синтаксисом функций Math.*
при использовании оператора (в данном случае +
):
"source": "Math.log(doc['SOME_FIELD'].value + 1)"
НЕ РАБОТАЕТ "source": "Math.log(1 + 1)"
НЕ РАБОТАЕТ
пока
"source": "doc['SOME_FIELD'].value"
РАБОТАЕТ "source": "1 + 1"
РАБОТАЕТ "source": "Math.log(1)"
РАБОТАЕТ
Полная трассировка стека:
{
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"NaN",
"^---- HERE"
],
"script": "NaN",
"lang": "painless"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "index",
"node": "69HAL8sMS-afWoTxhMteKw",
"reason": {
"type": "query_shard_exception",
"reason": "script_score: the script could not be loaded",
"index_uuid": "ASy6y5zxRpqMFONSLED6IQ",
"index": "index",
"caused_by": {
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"NaN",
"^---- HERE"
],
"script": "NaN",
"lang": "painless",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Variable [NaN] is not defined."
}
}
}
}
],
"caused_by": {
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"NaN",
"^---- HERE"
],
"script": "NaN",
"lang": "painless",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Variable [NaN] is not defined."
}
}
},
"status": 400
}