db.getCollection("test").aggregate([{ "$match" : { "itemId" : "1", "networkInfo.RanType" : { "$in" : [1, 2]}}}, { "$group" : { "_id" : "networkInfo.NrEarfcn", "NrArfcnList" : { "$addToSet" : "$networkInfo.NrEarfcn"}}}, { "$project" : { "NrArfcnList" : 1}}])
转换成java代码怎么写
Criteria nrCriteria1 = Criteria.where("itemId").is(taskItemId).and("networkInfo.RanType").in(1, 2);
Aggregation aggregation1 = Aggregation.newAggregation(Aggregation.match(nrCriteria1),Aggregation.group(
"networkInfo.NrEarfcn").addToSet("networkInfo.NrEarfcn").as("NrArfcnList"),
Aggregation.project("NrArfcnList"));
我自己写的转换出来 在"$group" : { "_id" : "$networkInfo.NrEarfcn" networkInfo.NrEarfcn前面多了一个美元符号 导致结果不对 怎么写java代码 做分组的时候去掉美元符号
得到我想要的结果就是这样