asList("$modifiedon",1000)
debe ser asList("$modifiedon","$createdon")
según la tubería de trabajo proporcionada por usted.
Como has hecho la edición. Puede ver que el problema es que está agregando "entonces" y "si no" al documento "$gt" en lugar de "si".
Así que en lugar de:
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")
)
)
)
));
Deberías hacer:
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")
)
)
));