MongoDB 4.0.2 版本中,地图中距离查询遇到的问题

MongoDB 4.0.2 版本中,地图中距离查询遇到的问题。

查询问题:当 maxDistance 参数加大时,返回值并不会变大,但在不用地图点距离进行查询时,是可以返回更多值的。
查找了很多资料,当看到D 4.2 版本官方资料中提到$limit 参数已取消时,怀疑可能是版本问题。
当加上 limit 2000 参数值后进行查询,真的可以返回更多记录。
(limit 默认值为100,但返回值在50左右后,就不返回更多值,所以开始也没往这里想)
回到服务器查询,发现MongoDB 版本是 4.0.2 (很多服务器我已安装了4.2.8 版本,开始没想到还有一台旧服务器还是4.0.2)

原查询MQL:

db.c_hotel.aggregate([
{ “$geoNear” :
{ “near” :{type:“Point”,coordinates:[120.009811504981,36.2892503005251]},
“maxDistance” : 90000.0,
“limit”:1000, #在4.0.2 版本起效,4.2 版本后不可用。
“spherical” : true,
“distanceField” : “distance”, “key” : “GDpos” }},

{ “KaTeX parse error: Expected '}', got 'EOF' at end of input: match" : { "and” : [{ “cnCityCode” : “3702”}, { “minPrices.Date” : 20230526}]}}, { “ u n w i n d " : " unwind" : " unwind":"minPrices”},
{ “KaTeX parse error: Expected '}', got 'EOF' at end of input: match" : { "and” : [{ “cnCityCode” : “3702”}, { “minPrices.Date” : 20230526}]}},

{ “KaTeX parse error: Expected '}', got 'EOF' at end of input: …" : { "_id" : "_id”, “CnName” : “ C n N a m e " , " A d d r C N " : " CnName","AddrCN" : " CnName","AddrCN":"AddrCN”,“GDpos” : “ G D p o s " , " d i s t a n c e " : " GDpos", "distance" : " GDpos","distance":"distance”},
“Date” : { “ l a s t " : " last" : " last":"minPrices.Date”},“Price” : { “ m i n " : " min" : " min":"minPrices.Price”}}},

{ “KaTeX parse error: Expected '}', got 'EOF' at end of input: …0, "CnName" : "_id.CnName”, “Date” : 1, “Price” : 1, “GDpos” : “ i d . G D p o s " , " d i s t a n c e " : " _id.GDpos", "distance" : " id.GDpos","distance":"_id.distance”}},
{ “$sort” : { “distance” : -1}} ]);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值