吗啡过滤错误
Morphia filtering wrong
我正在使用以下代码过滤评分高于 80 但低于 100 的餐厅
List<Restaurant_M> r = ds.find(Restaurant_M.class)
.field("grades.score").lessThan(100)
.field("grades.score").greaterThan(80)
.asList();
它正在运行,但我得到了 1 个额外的文档,如下所示
{
"_id" : ObjectId("572eb5df1d739cc73c21fab1"),
"address" : {
"building" : "65",
"coord" : [
-73.9782725,
40.7624022
],
"street" : "West 54 Street",
"zipcode" : "10019"
},
"borough" : "Manhattan",
"cuisine" : "American ",
"grades" : [
{
"date" : ISODate("2014-08-22T00:00:00Z"),
"grade" : "A",
"score" : 11
},
{
"date" : ISODate("2014-03-28T00:00:00Z"),
"grade" : "C",
"score" : 131
},
{
"date" : ISODate("2013-09-25T00:00:00Z"),
"grade" : "A",
"score" : 11
},
{
"date" : ISODate("2013-04-08T00:00:00Z"),
"grade" : "B",
"score" : 25
},
{
"date" : ISODate("2012-10-15T00:00:00Z"),
"grade" : "A",
"score" : 11
},
{
"date" : ISODate("2011-10-19T00:00:00Z"),
"grade" : "A",
"score" : 13
}
],
"name" : "Murals On 54/Randolphs'S",
"restaurant_id" : "40372466"
}
这没有在 80-100 范围内的分数。这打败了我。谁能告诉我为什么要退回这份文件?
编辑:
所以我试着用 JAVA 驱动程序来做这件事,令人惊讶的是我得到了完全相同的结果。代码如下
FindIterable<Document> r = collection.find(
Filters.and(Filters.gt("grades.score", 80), Filters.lt("grades.score", 100))
);
显然,在过去一周我做了所有的头部撞击之后,我无法用吗啡做这件事,所以我求助于 java 驱动程序,下面给出了正确的结果
Bson f1 = Filters.gt("score", 80);
Bson f2 = Filters.lt("score", 100);
Bson f3 = and (f1, f2);
MongoCursor<Document> c = collection.find(
elemMatch("grades", f3))
.iterator();
我正在使用以下代码过滤评分高于 80 但低于 100 的餐厅
List<Restaurant_M> r = ds.find(Restaurant_M.class)
.field("grades.score").lessThan(100)
.field("grades.score").greaterThan(80)
.asList();
它正在运行,但我得到了 1 个额外的文档,如下所示
{
"_id" : ObjectId("572eb5df1d739cc73c21fab1"),
"address" : {
"building" : "65",
"coord" : [
-73.9782725,
40.7624022
],
"street" : "West 54 Street",
"zipcode" : "10019"
},
"borough" : "Manhattan",
"cuisine" : "American ",
"grades" : [
{
"date" : ISODate("2014-08-22T00:00:00Z"),
"grade" : "A",
"score" : 11
},
{
"date" : ISODate("2014-03-28T00:00:00Z"),
"grade" : "C",
"score" : 131
},
{
"date" : ISODate("2013-09-25T00:00:00Z"),
"grade" : "A",
"score" : 11
},
{
"date" : ISODate("2013-04-08T00:00:00Z"),
"grade" : "B",
"score" : 25
},
{
"date" : ISODate("2012-10-15T00:00:00Z"),
"grade" : "A",
"score" : 11
},
{
"date" : ISODate("2011-10-19T00:00:00Z"),
"grade" : "A",
"score" : 13
}
],
"name" : "Murals On 54/Randolphs'S",
"restaurant_id" : "40372466"
}
这没有在 80-100 范围内的分数。这打败了我。谁能告诉我为什么要退回这份文件?
编辑: 所以我试着用 JAVA 驱动程序来做这件事,令人惊讶的是我得到了完全相同的结果。代码如下
FindIterable<Document> r = collection.find(
Filters.and(Filters.gt("grades.score", 80), Filters.lt("grades.score", 100))
);
显然,在过去一周我做了所有的头部撞击之后,我无法用吗啡做这件事,所以我求助于 java 驱动程序,下面给出了正确的结果
Bson f1 = Filters.gt("score", 80);
Bson f2 = Filters.lt("score", 100);
Bson f3 = and (f1, f2);
MongoCursor<Document> c = collection.find(
elemMatch("grades", f3))
.iterator();