
[英]How can I get per-document significant terms aggregations in Elasticsearch?
[英]How to use percentage score for significant terms aggregations in Nest
我正在尝试在 Nest 中重新创建以下聚合
"aggs": {
"related_organisations": {
"significant_terms": {
"field": "organisations.keyword",
"percentage": {},
"min_doc_count": 5
"size": 10
}
}
}
}
我无法弄清楚PercentageScore
的 function 表达式中 go 的含义
.Aggregations(a => a
.SignificantTerms("related_organisations", sigTerms => sigTerms
.Field("organisations.keyword")
.Size(10)
.PercentageScore(p => [[what goes here??]])
.MinimumDocumentCount(5)
我可以通过执行p => p
来编译它,但它不能正确构建查询并引发异常
System.TypeLoadException: GenericArguments[0], 'Nest.PercentageScoreHeuristic', on 'Nest.ReadAsFormatter`2[TRead,T]' violates the constraint of type parameter 'TRead'.
我也试过null
和new PercentageScoreHeuristicDescriptor()
没有运气。
正如评论中提到的,这是一个错误,正在修复中。
为了解决这个问题,直到我能够使用 Nest 的固定版本,我使用了脚本分数,并在其中复制了百分比分数:
.Aggregations(a => a
.SignificantTerms("related_organisations", sigTerms => sigTerms
.Field("organisations.keyword")
.Size(10)
.Script(s => s.Script("params._subset_freq/params._superset_freq"))
.MinimumDocumentCount(5)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.