0
在MongoDB Documentation我們已經得到了下面的例子:春數據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" } });
目前我正在尋找一個解決方案春季數據archieve此查詢。我的第一個方法是
Query.query(Criteria.where("metro")
.andOperator(Criteria.where("city").is("New York")
.and("state").is("NY")))
但這會導致下面的查詢
{ "metro" : { } , "$and" : [ { "city" : "New York" , "state" : "NY"}]}