【发布时间】:2020-04-21 13:22:33
【问题描述】:
我正在尝试使用存储桶聚合按特定标准执行分组文档,并为每个存储桶执行总和聚合。
下面是我的尝试
ISearchResponse<PaymentReportModel> paymentSearchResponse =
ConnectionToES.EsClient()
.Search<PaymentReportModel>
(s => s
.Index("payments")
.Query(q => q.MatchAll() )
.Aggregations(a => a
.Terms("paymentstatus_types", ts => ts
.Field(o => o.paymentstatus)
.Aggregations(aa => aa
.Sum("sumreceiptamount", sa => sa
.Field(o => o.totalreceiptamount)
)
)
)
)
);
var paymentRecords = paymentSearchResponse.Documents ; // Count = 0
付款索引中有 356 个文档,因此计数为零(0)。
我的 DTO 如下
public class PaymentReportModel
{
public string paymentid { get; set; }
public float? totalreceiptamount { get; set; }
public string paymentstatus { get; set; }
}
等效的 DSL 产生
"aggregations" : {
"paymentstatus_types" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "ReceivedByCollector",
"doc_count" : 36,
"sumreceiptamount" : {
"value" : 56914.14031982422
}
},
{
"key" : "CollectionAcknowledged",
"doc_count" : 17,
"sumreceiptamount" : {
"value" : 6802.75
}
},
{
"key" : "PayInSlipCreated",
"doc_count" : 10,
"sumreceiptamount" : {
"value" : 4183.0
}
},
{
"key" : "CollectionSuccess",
"doc_count" : 5,
"sumreceiptamount" : {
"value" : 27.0
}
}
]
}
}
}
我犯了什么错误?
【问题讨论】:
-
一定会帮助你的,我正忙于我的任务,今晚我会检查一下,我会在明天早上通知你
标签: c# elasticsearch nest dsl