Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-10917

Exists on geospatial fields

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.4.6
    • Component/s: Geo
    • Labels:
      None
    • Environment:
      Ubuntu 13.04.
    • ALL

      Let's have a 'places' collection with a geospatial indexed field named 'coordinates'. I need to get all the documents that have some coordinates filled in. So I try to do this:

      > db.places.find({"coordinates": {"$ne": null}})
      error: {
      "$err" : "geo field only has 1 element :: caused by :: $ne: null",
      "code" : 13068
      }

      Ok, let's check for 'exists' (though that's not what I really need).

      > db.places.find({"coordinates": {"$exists": true}})

      { "_id" : ObjectId("4eda5f338792904be4000397"), ... }

      But if we add something to the query:

      db.places.find({"deleted_at": null, "coordinates": {"$exists": true}})
      error: {
      "$err" : "geo field only has 1 element :: caused by :: $exists: true",
      "code" : 13068
      }

      So what's the proper way to get all documents that have a not null geospatial field?

            Assignee:
            Unassigned Unassigned
            Reporter:
            exoth Yuriy Trofimenko
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: