[SERVER-10917] Exists on geospatial fields Created: 26/Sep/13  Updated: 10/Dec/14  Resolved: 07/Oct/13

Status: Closed
Project: Core Server
Component/s: Geo
Affects Version/s: 2.4.6
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Yuriy Trofimenko Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu 13.04.


Issue Links:
Duplicate
duplicates SERVER-9389 Querying 2d indexes with $exists:fals... Closed
Operating System: ALL
Participants:

 Description   

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?



 Comments   
Comment by Daniel Pasette (Inactive) [ 07/Oct/13 ]

Thanks for the report.
This is a duplicate of SERVER-9389. Also, this is only for 2d, not 2dsphere index type.

Comment by Yuriy Trofimenko [ 26/Sep/13 ]

Just a little addition:

> db.places.find({"coordinates":

{"$ne": null}

, "deleted_at": null})
error: {
"$err" : "geo field only has 1 element :: caused by :: $ne: null",
"code" : 13068
}

> db.places.find({"coordinates":

{"$ne": null}

, "deleted_at": null, code: 'DME'})

{ "_id" : ObjectId("4eda607a8792904be4002b8b") ... }

Well, I don't understand how it works.

Generated at Thu Feb 08 03:24:23 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.