asList("$modifiedon",1000)
asList("$modifiedon","$createdon")
である必要があります あなたが提供する作業パイプラインに従って。
編集を行ったように。問題は、「if」ではなく「$gt」ドキュメントに「then」と「else」を追加していることであることがわかります。
代わりに:
AggregateIterable<Document> iterable = collection.aggregate(
asList( new Document("$redact",
new Document("$cond",
new Document("if",
new Document("$gt",
asList(new Document("$subtract",
asList("$modifiedon", "$createdon")
),1000 * 60 * 60 * 24)
).append("then", "$$KEEP")
.append("else", "$$PRUNE")
)
)
)
));
あなたがすべきこと:
AggregateIterable<Document> iterable = collection.aggregate(
asList( new Document("$redact",
new Document("$cond",
new Document("if",
new Document("$gt",
asList(new Document("$subtract",
asList("$modifiedon", "$createdon")
),1000 * 60 * 60 * 24)
)
).append("then", "$$KEEP")
.append("else", "$$PRUNE")
)
)
));