groovy - 为 "function_score"运行 groovy 脚本时出现问题?

标签 groovy elasticsearch

关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。












想改进这个问题?将问题更新为 on-topic对于堆栈溢出。

7年前关闭。




Improve this question



def score = 0;
// terms: list of tokens
for(term in terms) {
    q_term_freq = terms​.countBy { it }​[term]; // for frequency of each term in terms
    term_freq = _index[field][term].tf(); 
    doc_freq = _index[field][term].df(); 
    score += term_freq * doc_freq * q_term_freq;
};
score;

当我运行它时,我得到一个错误`GroovyScriptExecutionException[MissingPropertyException[No such property: terms\u200b for class: Script86.

出了什么问题?阿法克countBy是有效的功能。

最佳答案

\u200b是零宽度空间的 unicode。

重写脚本或确保 terms 中不存在 unicode 字符.

关于groovy - 为 "function_score"运行 groovy 脚本时出现问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28184611/

相关文章:

java - 在 Tomcat 中 session 集群 Grails 应用程序

apache - Apache 后面的 Grails 应用程序看不到/访问手动设置的 header

nest - 在 Elasticsearch 中,是一个可查询的集合,同时将其添加到索引中

c# - 如何使用NEST Library在Elasticsearch中的嵌套对象中的同一字段上搜索多个值?

elasticsearch - 如何在 Spring Data ES 3.2.0.M1 中使用 High Level Rest Client

gradle - 如何在复合项目中递归执行构建?

java - Groovy 或 Java 中是否有任何类型的算术安全导航运算符?

ElasticSearch Shield 与 Azure Active Directory 的集成

grails - 如何防止 Grails 尝试使用名称为 Service 的域类作为服务?

java - 在 Elastic Search 中设置动态日期格式