[SERVER-20687] $geoWithin queries not hitting 2dsphere index Created: 29/Sep/15 Updated: 08/Oct/15 Resolved: 08/Oct/15 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Geo, Index Maintenance |
| Affects Version/s: | 3.0.5 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Andrew Kouri | Assignee: | Wan Bachtiar |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Operating System: | ALL |
| Steps To Reproduce: | Create a collection from MapReduce query that contains geoJson points in the value.location field. Add a 2dsphere index to that embedded field. Run a $geoWithin query such as: "value.avg_location" : { } |
| Participants: |
| Description |
|
When I run a query on an indexed location field (which contains geoJSON points) I notice that the query is doing a collection scan. Deleting the index and running the query takes about 5 minutes. After adding the index back again, the query still takes about 5 minutes. Here are the steps I've taken to debug: http://www.andrewkouri.com/debugging-mongodbs-2dsphere-geoindex/ |
| Comments |
| Comment by Wan Bachtiar [ 08/Oct/15 ] | |||||||||||||||||||||||||||||||||||
|
Hi Andrew, Thanks for the report. As noted in MongoDB documentation, only the 2d geospatial index supports the $polygon operator : http://docs.mongodb.org/manual/reference/operator/query/polygon/#behavior Please use the $geometry operator to specify a polygon shape in GeoJSON format, if the index is 2dsphere. Regards, Wan | |||||||||||||||||||||||||||||||||||
| Comment by Andrew Kouri [ 29/Sep/15 ] | |||||||||||||||||||||||||||||||||||
|
Update: It appears that the index miss only happens for the "old" type of geo queries:
The following uses an "IXSCAN":
|