mongodb:执行geoNear聚合时无法获取查询执行程序

编程入门 行业动态 更新时间:2024-10-26 08:20:40
本文介绍了mongodb:执行geoNear聚合时无法获取查询执行程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

执行以下汇总时

db.Activities.aggregate([ { $geoNear: { near: { coordinates: [ -73.99279 , 40.719296 ] }, distanceField: "location.calculated", spherical: true, } } ])

我遇到以下错误

uncaught exception: aggregate failed: { "errmsg" : "exception: geoNear command failed: { ok: 0.0, errmsg: \"can't get query executor\" }", "code" : 16604, "ok" : 0 }

当我运行geoNear命令时,它运行正常.

when i run the geoNear command, it works fine.

db.runCommand( { geoNear: "Activities" , near: [ -73.99279 , 40.719296 ], spherical: true, })

任何想法我在做什么?

Any ideas what i am doing worng ?

推荐答案

问题可能是:

  • 您在集合Activities中缺少"2dsphere"索引.
  • 集合Activities
  • 中有多个地理位置索引
  • You are missing a "2dsphere" index in collection Activities.
  • There are multiple geo indexes in collection Activities
  • 在Mongo shell中运行此代码以查看所有索引

    Run this code in Mongo shell to see all the indexes

    db.Activities.getIndexes()

    更多推荐

    mongodb:执行geoNear聚合时无法获取查询执行程序

    本文发布于:2023-11-22 13:00:42,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1617508.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:程序   mongodb   geoNear

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!