DSL
"query": {
"function_score": {
"script_score": {
"script": "_score * doc['date_date_sore'].value.getTimeInMillis()"
}
}
}
日志
{"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"_score * doc['date_date_sore'].value.getTimeInMillis()"
,
" ^---- HERE"
],
"script": "_score * doc['date_date_sore'].value.getTimeInMillis()",
"lang": "painless"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "book",
"node": "g8_FSKX_QjWiKudI5I-s7A",
"reason": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"_score * doc['date_date_sore'].value.getTimeInMillis()"
,
" ^---- HERE"
],
"script": "_score * doc['date_date_sore'].value.getTimeInMillis()",
"lang": "painless",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "dynamic method [org.elasticsearch.script.JodaCompatibleZonedDateTime, getTimeInMillis/0] not found"
}
}
}
]
},
"status": 400}
"query": {
"function_score": {
"script_score": {
"script": "_score * doc['date_date_sore'].value.getTimeInMillis()"
}
}
}
日志
{"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"_score * doc['date_date_sore'].value.getTimeInMillis()"
,
" ^---- HERE"
],
"script": "_score * doc['date_date_sore'].value.getTimeInMillis()",
"lang": "painless"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "book",
"node": "g8_FSKX_QjWiKudI5I-s7A",
"reason": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"_score * doc['date_date_sore'].value.getTimeInMillis()"
,
" ^---- HERE"
],
"script": "_score * doc['date_date_sore'].value.getTimeInMillis()",
"lang": "painless",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "dynamic method [org.elasticsearch.script.JodaCompatibleZonedDateTime, getTimeInMillis/0] not found"
}
}
}
]
},
"status": 400}
1 个回复
hubiao
赞同来自: tacsklet
人家已经告诉 是org.elasticsearch.script.JodaCompatibleZonedDateTime, getTimeInMillis没有这个方法,那么顺着这个提示去找它提供 了哪些方法,于是在https://www.elastic.co/guide/e ... eTime 找着了!
解决方法是
doc['date_date_sore'].value.getTimeInMillis()改为 doc['date_date_sore'].value.getMillis()