MongoDBドキュメントには、次の例があります。
db.factories.insert( { name: "xyz", metro: { city: "New York", state: "NY" } } );
db.factories.ensureIndex( { metro : 1 } );
// this query can use the above index:
db.factories.find( { metro: { city: "New York", state: "NY" } } );
私は現在、このクエリを春のデータにアーカイブするための解決策を探しています。私の最初のアプローチは
Query.query(Criteria.where("metro")
.andOperator(Criteria.where("city").is("New York")
.and("state").is("NY")))
しかし、これは次のクエリになります
{ "metro" : { } , "$and" : [ { "city" : "New York" , "state" : "NY"}]}