在Elasticsearch script_score中访问query.boost和doc.length

时间:2019-02-20 10:22:56

标签: elasticsearch

我正在尝试在Elasticsearch中编写一个自定义分数,该分数允许我将查询中的单词数传递到我的计算中。使用脚本相似性或function_score脚本似乎无法实现。以下是我想要的无痛脚本,但是我发现我无法通过脚本相似性来做到这一点,因为据我所知,我无法将参数传递到脚本相似性中(params.queryPhraseLength案件)。我以为我可以使用脚本化的function_score来做到这一点,但据我所知,脚本化功能分数仍然无法访问doc.length或query.boost...。我该如何实现?

double length = params.queryPhraseLength; if(doc.length > params.queryPhraseLength){length  = doc.length;} return 100 * query.boost * 1 / length 

0 个答案:

没有答案
相关问题