[英]ElasticSearch C# NEST - scriptscorefunction not working
I'm trying to write a script score function which boosts items who belong to just one category. 我正在尝试编写脚本评分功能,以提高仅属于一个类别的项目。
new ScriptScoreFunction
{
Script = new ScriptQuery
{
Lang = "painless",
Source = "doc['categories'].values.length == 1",
},
Weight = 10
}
The code below does not seem to work. 下面的代码似乎不起作用。 I'm getting a "bad response code" from the API.
我从API获得“响应错误代码”。 What am I doing wrong?
我究竟做错了什么?
solved by using this as the source of my script: 通过使用它作为我的脚本的源解决:
if (doc['categories.slug'].values.length == 1) { return 1; } return 0;
NOTE: 'slug' is a property of the property 'category'. 注意:“ slug”是属性“ category”的属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.