mongodb - spring-data-mongo aggregate 筛选两个字段相等
ringa_lee
ringa_lee 2017-05-02 09:23:59
0
0
989

在使用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")
);
List<Events2> results = events2Data.agreagate(agg);

请问各位是哪里有错吗,或者,有什么方法能比较一下两个字段是否相等吗?拜谢~

ringa_lee
ringa_lee

ringa_lee

répondre à tous(0)
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!