[英]MongoDB Aggregation sum the results
有一些很好的示例,我想在Scala中使用Mongo的Aggregation Pipeline聚合以下内容。
想要获得总价PriceAmt
。
任何带有一些出色的Scala示例的良好URL都会有很大的帮助。.以下是从MongoDB中检索到的JSON。
{
"_id": ObjectId("5269723bd516ec3a69f3639e"),
"Id": ObjectId("5269723ad516ec3a69f3639d"),
"results": [
{
"Id": "526971f5b5b8b9148404623a",
"pricingResult": {
"TxId": 0,
"PriceId": "Large_Batch_1",
"Errors": [ ],
"Disposition": [
{
"GroupId": 1,
"PriceAmt": 20,
"Status": "Priced Successfully",
"ReasonCode": 0,
"PricingMethodologyId": 2,
"Lines": [{ "Id": 1 }]
}
]
}
},
{
"ClaimId": "526971f4b5b8b91484046229",
"pricingResult": {
"TxId": 0,
"PriceId": "Large_Batch_1",
"Errors": [ ],
"Disposition": [
{
"GroupId": 1,
"PriceAmt": 20,
"Status": "Priced Successfully",
"ReasonCode": 0,
"PricingMethodologyId": 2,
"Lines": [{ "Id": 1 }]
}
]
}
}
]
}
我认为这不是一个有效的问题,但是如果您正在寻找聚合框架和scala的示例,请查看以下链接:
然后,您可以尝试使用mongodb中的示例使用scala复制一些结果
官方Scala驱动程序Casbah支持聚合框架。
请看一下文档 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.