[SERVER-12618] $near query not working with compound 2dsphere index Created: 05/Feb/14 Updated: 10/Dec/14 Resolved: 05/Feb/14 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Geo |
| Affects Version/s: | 2.5.5 |
| Fix Version/s: | None |
| Type: | Question | Priority: | Major - P3 |
| Reporter: | Stuart Hall | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||
| Participants: | |||||
| Description |
|
Running the following query:
...on a collection with the following shape of documents:
...with the following geospatial index:
....results in the following error being raised in the mongod logs:
Can you confirm why this might be happening? |
| Comments |
| Comment by Stuart Hall [ 05/Feb/14 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks Hari. That was it - $nearSphere works fine You can close this ticket. I'll continue with our testing.... | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by hari.khalsa@10gen.com [ 05/Feb/14 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The documentation is not entirely clear here, but I think this does work as designed.
is a query that wants things near a point but on a flat surface. This can use a 2d index. Because you're asking for a flat $near query here so we do not use 2dsphere indices as they cannot be flat.
is a query that wants things near a point on a sphere. This can use 2d or a 2dsphere index.
is a query that wants things near a point, but the point implies a spherical geometry, so we try to use the 2dsphere index. And yes, if you have a compound 2dsphere index you must have predicates over the fields that prefix the 2dsphere-indexed field or we cannot use that index for a near search | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Stuart Hall [ 05/Feb/14 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
For your reference, here is a sample complete document:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Stuart Hall [ 05/Feb/14 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Here you go:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Adam Comerford [ 05/Feb/14 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Can you post the indexes you have in place on the stuarttest.routeResult collection for reference also? Asking for the full definition of the indexes so we can try to reproduce, especially since the error looks to be related to an issue finding the geo index here. Thanks, Adam |