2
我有一個文件在MongoDB中如下:乘3的值,從提取的MongoDB在java中
"sentiment" : {
"Value" : 0,
"high" : 0
},
"quality" : {
"Value" : 0,
"high" : 0
},
"intensity" : {
"Value" : 0,
"low" : 0
}
現在我想乘quality.value intensity.value sentiment.value然後在這裏返回結果是我的代碼:
DBObject groupFields = new BasicDBObject("_id", "$Added");
DBObject project = null;
groupFields.put("value1", new BasicDBObject("$sum",
"$sentiment.Value"));
groupFields.put("value2", new BasicDBObject("$sum",
"$quality.Value"));
groupFields.put("value3", new BasicDBObject("$sum",
"$intensity.Value"));
groupFields.put("count", new BasicDBObject("$sum", 1));
DBObject groupBy = new BasicDBObject("$group", groupFields);
stages.add(groupBy);
DBObject valueMultiply = new BasicDBObject("$multiply", args);
project = new BasicDBObject("_id", 0);
project.put("value", valueMultiply);
AggregationOutput output = collectionG.aggregate(stages);
現在我的問題是這樣的一行:
DBObject valueMultiply = new BasicDBObject("$multiply", args);
我不知道如何做他的乘法value1和value2和value3 ...
任何人都可以幫忙嗎?
真棒回答@BatScream ...感謝萬萬:) – 2015-03-03 15:13:12