我想根据嵌套字段值计算我在 elasticsearch 上的查询得分。这是我的文档的示例:
{
"title": "Mr",
"first_name": "Barry",
"last_name": "White",
"experiences": [
{
"name": "parachute",
"values": {
"last_year": 4,
"older": 12
}
},
{
"name": "base jump",
"values": {
"last_year": 2,
"older": 1
}
}
]
}
我想要的是根据经验数量和范围(去年的值更重要)过滤和排名查询。问题是:我如何才能获得过滤经验的价值?
这是我的查询的简化版本:
{
"query" :{
"nested": {
"path": "experiences",
"query":{
"function_score" : {
"functions": [
{
"filter": {"term": { "experiences.name": "parachute"} },
"script_score" : {
"script" : {
"lang": "painless",
"inline": "_score * doc['experiences.values.older'].value" //Here I want to get the "older" value of "parachute": 12
}
}
}
]
}
}
}
}
}
希望有办法解决这个问题...
在此先感谢您的帮助