find in a mongodb collection documents using FindIterable<Document> i cant get result if values of documents are also documents

Viewed 22

I try to find a document in my collection that contains document as well. when i search only with primitive fields like the name and age it works but when i add the grades its doesn't find the document in my collection

List<Bson> bsonList = new arrayList<>();
bsonList.add(new Document("name", "john"));
bsonList,add(new Document("age", 19));
Map<String, Integer> = grades = new HashMap<>();
grades.put("math", 9);
grades.put("english", 10);
bsonList.add(new Document("grades", grades);

FindIterable<Document> result = applicationContext.getBean(MongoConnection.class)
    .getCollection(myDb, myCollection)
    .find(Filters.and(bsonList));
0 Answers
Related