I have got below document . I need to match with the requestParam System Bob with the below collection and need to get the result value if requestParam matches with the Email Systems.Bob.System.
Here RequestParam is system
{
"_id" : ObjectId("5f0890e870e631865877e"),
"user" : "testuser",
"Email" : "[email protected]",
"Batch Systems" : [
"STAR",
"STORY",
"ITEMS",
],
"Email Systems" : [
{
"Bob" : {
"System" : "Bob",
**"result"** : true
}
},
{
"Wild" : {
"System" : "Wild",
"result" : true
}
},
{
"CRaft" : {
"System" : "Craft",
"result" : false
}
}
]
}
I have tried with the below syntax , getting the java.lang.ClassCastException: com.mongodb.client.internal.AggregateIterableImpl cannot be cast to java.util.ArrayList . Can anyone tell me what is wrong with the below code and help me with the synatx .
MongoDatabase database = this.mongoClient.getDatabase(this.database);
MongoCollection<Document> user = database.getCollection(COLLECTION);
Document userQuery = new Document();
String searchString = new String(system);
AggregateIterable<Document> user1 =users.aggregate((List<? extends Bson>) new Document("$project",
new Document("Email Systems",
new Document("$match",
new Document("Email Systems.BobSystem",searchString)))));