[SERVER-20994] 2dsphere index Created: 18/Oct/15 Updated: 18/Oct/15 Resolved: 18/Oct/15 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Geo |
| Affects Version/s: | 2.6.5 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Elyes Gherib | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Operating System: | ALL |
| Participants: |
| Description |
|
Config. : single-node, unsharded, MongoDB v2.6.5 running on Mac OS X Yosemite. I have a collection of about 240,000 documents. Each document contains many fields, and a "location" field which in turn always has two sub-fields: latitude and longitude. My backend needs to perform geospatial queries on the collection. I thusly created a compound index with the fields declared in the following order:
This index works, but is not optimal, as the MongoDB staff told me during the Paris Mongo Days conference. I therefore changed the order of the fields, according to their advice. The order became:
Furthermore, this page : states the following regarding the 2dsphere index in MongoDB v2.6: However, when I changed the order of the index' fields and placed the location field in the last position, I get the following error message : planner returned error: unable to find index for $geoNear query |
| Comments |
| Comment by Elyes Gherib [ 18/Oct/15 ] |
|
Duly noted. Regards, |
| Comment by Ramon Fernandez Marina [ 18/Oct/15 ] |
|
Thanks for the followup elyesgherib. Please note that the SERVER project is for reporting bugs or feature suggestions for the MongoDB server. For MongoDB-related support discussion please post on the mongodb-user group or Stack Overflow with the mongodb tag, where your question will reach a larger audience. A question like this involving more discussion would be best posted on the mongodb-user group. See also our Technical Support page for additional support resources. Regards, |
| Comment by Elyes Gherib [ 18/Oct/15 ] |
|
Please close this, it's my mistake. It works now. |
| Comment by Elyes Gherib [ 18/Oct/15 ] |
|
Update: rebuilding the indexes or restarting the node doesn't fix the problem. |
| Comment by Ramon Fernandez Marina [ 18/Oct/15 ] |
|
elyesgherib, can you please send the output of db.col.getIndexes() for this collection as well as the query you're running? Thanks, |