i have an aggregation query given below which i need to pass in as a json string to java app to execute it.
Hi,
Try separating the aggregation pipeline stages, and then parse using Document method.
For example:
Document unwind = Document.parse("{$unwind:'$results'}");
Document match = Document.parse("{$match:{'results.studentid':'11'}}");
List<Document> pipeline = asList(unwind, match);
AggregateIterable<Document> iterable = database.getCollection("collection").aggregate(pipeline);
See also MongoDB Java driver: Aggregation
Regards,
Wan.