[SERVER-4572] Geospatial index cannot be used in $and criteria of a query? Created: 28/Dec/11 Updated: 11/Jul/16 Resolved: 18/Dec/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Geo, Querying |
| Affects Version/s: | 2.0.2 |
| Fix Version/s: | 2.5.5 |
| Type: | Question | Priority: | Major - P3 |
| Reporter: | Mark Sievers | Assignee: | hari.khalsa@10gen.com |
| Resolution: | Done | Votes: | 17 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Participants: | |||||||||
| Description |
|
Question posted on mongodb-user here http://groups.google.com/group/mongodb-user/browse_thread/thread/41173a4a2c62f0be Quick synopsis is I'm getting this error back from the shell Wed Dec 28 12:39:01 uncaught exception: error { }, { identity.type_name: \"airport\" } ] }", when using $near on a geospatial index in an $and query. Pulling the $near outside the $and gets the expected behavior. I can't see any caveats in the docs on geospatial queries or $and that indicates any restrictions here. |
| Comments |
| Comment by Tobias Gassmann [ 18/Oct/13 ] | ||||||||||||||||||||||
|
Using $geoWithin with $centerSphere will do the job without throwing an error. But the index will not be used after all. The underlying problem of this bug is that queries return a BasicCursor although a S2Cursor on the geospatial-index could have been used. Thus performance degrades dramatically as collections grow. | ||||||||||||||||||||||
| Comment by olivier stevens [ 18/Oct/13 ] | ||||||||||||||||||||||
|
I have got the same Issue. I finally use $geoWithin with $centerSphere that does the job for me. | ||||||||||||||||||||||
| Comment by Tobias Gassmann [ 03/Sep/13 ] | ||||||||||||||||||||||
|
A similar problem occurs when querying against a compound 2dsphere-index using $and. The index can obviously not be found and a BasicCursor is created. $and-queries using the implicit way (separated by ',') are executed correctly with a S2Cursor. (version 2.4.6) | ||||||||||||||||||||||
| Comment by pan shangbin [ 11/Jul/13 ] | ||||||||||||||||||||||
|
I have the same problem. I just want to find one document with the condition ]} }, { _id: ObjectId('51c27ab3fb06280efea5c654') } ] }", | ||||||||||||||||||||||
| Comment by Daniel Pasette (Inactive) [ 26/Jun/13 ] | ||||||||||||||||||||||
|
We plan for | ||||||||||||||||||||||
| Comment by Jacek Z?owocki [ 24/Jun/13 ] | ||||||||||||||||||||||
|
I'm so stuck with this one.. My case is very simple, yet this issue is critical and prevents me from using MongoDB in this project at all. Just to say it simple: I've got documents storing lines (LineString GeoJSON objects) using 2dsphere index. Eg.:
I need to get all the documents, containing lines that run near two (or more) specified points: [40,5], [43,7]. The correct way to do that would be:
It's still impossible in version 2.4. | ||||||||||||||||||||||
| Comment by Nelson LEVERT [ 21/May/13 ] | ||||||||||||||||||||||
|
Hello Guys, I'm having the same problem in my project "can't find special index: 2d for":
Any update on this issue ? | ||||||||||||||||||||||
| Comment by Arvind Srinivasan [ 22/Jan/13 ] | ||||||||||||||||||||||
|
I just verified that this is broken on 2.2.2 as well. Please fix this! | ||||||||||||||||||||||
| Comment by Arvind Srinivasan [ 06/Nov/12 ] | ||||||||||||||||||||||
|
I'm experiencing the same issue. Here are the details: Moped::Errors::QueryFailure (The operation: #<Moped::Protocol::Query > } ] }" Here is how I have defined index: index( { 'actor.l' => "2d"}, {min: -200, max: 200, background: true, sparse: true}) I'm using Mongoid 3.0 and MongoDB 2.0.4 | ||||||||||||||||||||||
| Comment by raxit sheth [ 05/Nov/12 ] | ||||||||||||||||||||||
|
@Dan Can you help me with this query, i have tried putting $near out and $and inside, but not working Ref : http://groups.google.com/group/mongodb-user/browse_thread/thread/beaa1f32434c9e38 Raxit | ||||||||||||||||||||||
| Comment by raxit sheth [ 05/Nov/12 ] | ||||||||||||||||||||||
|
Is there any fix avail in non-production-ready version? as geoquery can only have one index field, and $and not working it is creating too much restrictions and great if any workaround is avail earliest! | ||||||||||||||||||||||
| Comment by Adam Kusmierz [ 05/Sep/12 ] | ||||||||||||||||||||||
|
$or doesn't work as well | ||||||||||||||||||||||
| Comment by William Zola [ 01/Aug/12 ] | ||||||||||||||||||||||
|
Attached reproducible test case. | ||||||||||||||||||||||
| Comment by Marc Weil [ 14/Feb/12 ] | ||||||||||||||||||||||
|
I am having this problem too. It's especially problematic given that I'm using an ODM in Ruby to perform these queries, and I'd love to not have to introduce special cases into all my code to get around this. |