在我的mongodb数据库中使用游标,需要关于修复查询的指导吗
所以现在我想用游标来查找所有对团体有益的餐厅,它们的价格范围小于或等于3,并且有50多个评论,这些评论至少有5张“有用”的选票 但到目前为止,这个查询没有发现任何问题,那么它有什么问题吗 这也是到目前为止我对光标的想法,如果您发现有任何问题,请随意更改 var myCursor=db.business.find({$and:[{“attributes”:/.goodforgroup:True./i},{review\u count:{$gte:50},{“attributes.restaurantpriceRange2”:{$lte:3}]},{business\u id:True,\u id:false})在我的mongodb数据库中使用游标,需要关于修复查询的指导吗,mongodb,count,attributes,cursor,Mongodb,Count,Attributes,Cursor,所以现在我想用游标来查找所有对团体有益的餐厅,它们的价格范围小于或等于3,并且有50多个评论,这些评论至少有5张“有用”的选票 但到目前为止,这个查询没有发现任何问题,那么它有什么问题吗 这也是到目前为止我对光标的想法,如果您发现有任何问题,请随意更改 var myCursor=db.business.find({$and:[{“attributes”:/.goodforgroup:True./i},{review\u count:{$gte:50},{“attributes.restauran
首先,您不需要$and,在查询中,mongodb默认执行$and。
其次,您试图查询文档的键,这是不可能的。
第三,GoodForGroup应该有一个布尔值。这里不需要正则表达式 请运行:
db.business.find({"attributes.GoodForGroups": true},{review_count:{$gte:50}},{"attributes.RestaurantsPriceRange2":{$lte:3}})
嘿,先生,我现在修好了,我发布了一个新问题,你能看一下吗?还有,先生,我尝试过这个,但是得到了0,db.business.count({$and:[{{“attributes”:/*GoodForGroups:True.*/I},{review\u count:{$gte:50},{“attributes.restaurantpriceRange2”:{$lte:3})0
while(myCursor.hasNext()){
db.reviews.find({$and:[{business_id:myCursor.next().business_id},{"useful":{$gte: 5}}]});
}
db.business.find({"attributes.GoodForGroups": true},{review_count:{$gte:50}},{"attributes.RestaurantsPriceRange2":{$lte:3}})