[SERVER-2331] Allow more than one geo index per collection Created: 05/Jan/11 Updated: 06/Dec/22 Resolved: 01/Feb/16 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Geo, Index Maintenance |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Brian Hempel | Assignee: | Backlog - Query Team (Inactive) |
| Resolution: | Done | Votes: | 20 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Assigned Teams: |
Query
|
||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||
| Participants: | |||||||||||||||||
| Description |
|
It'd be nice to allow more than one geospatial index in a collection. I currently have a collection where this might be useful--two different keys in a document whose locations represent different things. |
| Comments |
| Comment by Siyuan Zhou [ 08/Feb/16 ] | |||||||||||||||||||||||||||||
|
For $geoNear command and $geoNear aggregation, it returns an error. It's highly recommended to use $geoNear query operator rather than $geoNear command unless you need the $distance output or run on a sharding cluster. $geoNear query operator supports multiple indexes, because it allows users to specify the field name. For $geoNear aggregation operator, it's a limitation without workaround. | |||||||||||||||||||||||||||||
| Comment by Robert Pocklington [ 01/Feb/16 ] | |||||||||||||||||||||||||||||
|
@Neville - that was the reason I referenced this issue. It's confusing as you can create multiple indexes, but only one will ever be used (the JIRA issue could be updated to "$geoNear doesn't work with multiple geo indexes") as per MongoDB docs. I am using legacy 2d coordinates - are you saying this isn't a limitation with 2dsphereIndexVersion v2? | |||||||||||||||||||||||||||||
| Comment by Neville Dipale [ 01/Feb/16 ] | |||||||||||||||||||||||||||||
|
I was going to ask about that, which index is used when there are multiple? | |||||||||||||||||||||||||||||
| Comment by Ramon Fernandez Marina [ 01/Feb/16 ] | |||||||||||||||||||||||||||||
|
rpocklin, as nevi_me correctly points out it is already possible to have more than one geo index per collection. Here's a sample output of getIndexes() on a collection with two geo indices:
Please note that the $geoNear command and aggregation operator have some limitations:
| |||||||||||||||||||||||||||||
| Comment by Neville Dipale [ 22/Jan/16 ] | |||||||||||||||||||||||||||||
|
Can someone explain what the gist of the issue is? I have a collection that has 3 geo indices (2dsphereIndexVersion 2). Is the issue allowing this to happen, or is it for the legacy 2d index? | |||||||||||||||||||||||||||||
| Comment by Robert Pocklington [ 10/Mar/15 ] | |||||||||||||||||||||||||||||
|
IMO this is a major limitation of using geo searching in MongoDB. It'd be great to understand why this limitation exists and some kind of estimate of when this will get looked at. | |||||||||||||||||||||||||||||
| Comment by Nicholas Knize [ 19/Jul/11 ] | |||||||||||||||||||||||||||||
|
I'm not sure I understand the wording for this issue. I assume the request is more than 1 geoIndex per document in a collection. This dovetails nicely w/ SERVER-3325 and | |||||||||||||||||||||||||||||
| Comment by Nicholas Knize [ 19/Jul/11 ] | |||||||||||||||||||||||||||||
|
Anyone else working this? I'm in need of this capability and if no one is working on it I'm going to start, but I'm not looking to duplicate an in-work effort. |