在使用spring-data-mongo做统计时,需要比较两个字段是否相等,比如 l==qzt
就像find中查询
db.dbName.find({$where:"this.l=this.qzt"})
这段代码是能查询出来的
但是在使用spring-data-mongo Aggregation的时候 就报以下错误
"errmsg" : "$where is not allowed inside of a $match aggregation expression" , "code" : 16395
我是这样用的:
Criteria c = Criteria.where("$where").is("this.qzt==this.l"); Aggregation agg =Aggregation.newAggregation( Aggregation.match(c), Aggregation.group("qzc").count().as("z"), Aggregation.project("z").and("qzc").previousOperation(), Aggregation.sort(Sort.Direction.DESC, "z") ); Listresults = events2Data.agreagate(agg);
请问各位是哪里有错吗,或者,有什么方法能比较一下两个字段是否相等吗?拜谢~