我正在使用 Elasticsearch 2.x 版本。数据映射如下。
"mappings":{
"anchor_type": {
"properties": {
"image_url": {"type":"string"},
"vocab": {"type":"nested"}
}
}
}
"vocab" 由一个类似的数组组成{string, float}
,
[ {"human", 0.1}, {"dog", 0.3}, {"cat",0.5}]
我要做的是,当查询“dog”时,我希望最终得分为0.3 / 3,即匹配词的得分除以“vocab”中的项目数。
我使用function_score
and检索 0.3 工作script_score
,但未能获得 3。我认为类似的东西doc['vocab'].value.size()
可以工作,但它没有......
有人可以帮我吗?请...