0
私はこれを行いましたが、作成者フィールドに2つの特定の値と他の値が含まれているすべての文書を返します。配列フィールドに2つの特定の値しか含まれていないすべての文書を見つける方法
Document authors = new Document("authors","firstValue")
.append("authors", "secondValue");
MongoCursor<Document> cursor = collection.find(authors).iterator();
try {
while (cursor.hasNext()) {
Document doc = cursor.next();
System.out.println(doc.get("title")+ " " + doc.get("authors"));
}
}
finally {
cursor.close();
}
client.close();
これらの2つの値のみを含むドキュメントのみを検索したいとします。