如何在脚本分数中使用字段的最大分数 - ElasticSearch [英] How to use maximum score of a field in script score - ElasticSearch

查看:470
本文介绍了如何在脚本分数中使用字段的最大分数 - ElasticSearch的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ElasticSearch 2.4.0。使用script_score,我正在计算自定义分数,如

  {script:return(((doc.field_a.value )* 0.5)+(_score * 0.5));} 

我想要一些对field_a值的影响):

  max_score = doc.field_a.values.max(); 
return(((doc.field_a.value)* 0.5)/ max_score +(_score * 0.5));

任何帮助赞赏。

解决方案

请检查您正在调用的值api。我认为它只返回一个值


I'm using ElasticSearch 2.4.0 . Using the script_score, I'm calculating custom score like

{"script":"return ( ((doc.field_a.value)* 0.5) + (_score * 0.5) );"}

I want something like (some normalisation effect on the field_a value):

max_score = doc.field_a.values.max(); 
return ( ((doc.field_a.value)* 0.5)/max_score + (_score * 0.5) );

Any help appreciated.

解决方案

Please check on the values api you are calling. I think its returning only a single value

这篇关于如何在脚本分数中使用字段的最大分数 - ElasticSearch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆