アグリゲーターフレームワークを使用してmongoDBを照会する方法に取り組んでいます。集計を作成しましたが、次の例外が引き続き発生します。
Pipeline::run(): 認識されないパイプライン op \"$or"
DBObjectsをクエリに追加または追加するときに正しく理解できれば、それらは暗黙的に操作として追加されます。私は今とても疲れているかもしれませんが、集約フレームワークを使用して条件を 1 つまたは 2 つ考え出すことはできません。
以下は私のコードのスニペットです:
DBObject matchCriteriaTransmitter = new BasicDBObject("$match",
new BasicDBObject("someKey": "someValue").
append("someKey": "someValue"));
DBObject matchCriteriaReceiver = new BasicDBObject("$match",
new BasicDBObject("someKey": "someValue").
append("someKey": "someValue"));
BasicDBList or = new BasicDBList();
or.add(matchCriteriaTransmitter);
or.add(matchCriteriaReceiver);
DBObject matchCriteria = new BasicDBObject("$or", or);
DBObject sortCriteria = new BasicDBObject("$sort",
new BasicDBObject("compoundIndex.scenarioDtg", -1));
DBObject limitCriteria = new BasicDBObject("$limit", 1);
DBCollection collection = dao.getCollection();
AggregationOutput output = collection.aggregate(matchCriteria, sortCriteria, limitCriteria);
どんな洞察も大歓迎です!