[SERVER-1669] Performing Queries with GeoSpatial Indexes Cause Non-Geospatial results to not return items without location data. Created: 24/Aug/10 Updated: 12/Jul/16 Resolved: 26/Aug/10 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Geo, Index Maintenance |
| Affects Version/s: | 1.4.4, 1.6.1 |
| Fix Version/s: | 1.7.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Sasank Reddy | Assignee: | Eliot Horowitz (Inactive) |
| Resolution: | Done | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
PyMongo, 1.6.1 and 1.4.4 MongoDB, Ubuntu |
||
| Attachments: |
|
| Operating System: | ALL |
| Participants: |
| Description |
|
I created a simple python script to test out geospatial indexes which Basically, what I'm doing in the script is the following: Creating a Geo Index for the "location" field. 1.) I do a find with no query arguments (results are all 6 documents)
What I don't understand is why doing a query with a geo index and The output of my python program is shown below. Can be reproduced on Create Geo Index for location Print Everything {u'_id': ObjectId('4c73ce215c59731428000000'), u'issue': u'0', u'created': datetime.datetime(2010, 8, 24, 13, 50, 25, 778000)} {u'_id': ObjectId('4c73ce215c59731428000001'), u'issue': u'1', u'created': datetime.datetime(2010, 8, 24, 13, 50, 25, 778000)} {u'_id': ObjectId('4c73ce215c59731428000002'), u'issue': u'2', u'created': datetime.datetime(2010, 8, 24, 13, 50, 25, 778000)} {u'_id': ObjectId('4c73ce215c59731428000003'), u'issue': u'0', u'location': [34.0, -118.0], u'created': datetime.datetime(2010, 8, 24, 13, 50, 25, 778000)} {u'_id': ObjectId('4c73ce215c59731428000004'), u'issue': u'1', u'location': [34.0, -118.0], u'created': datetime.datetime(2010, 8, 24, 13, 50, 25, 778000)} {u'_id': ObjectId('4c73ce215c59731428000005'), u'issue': u'2', u'location': [34.0, -118.0], u'created': datetime.datetime(2010, 8, 24, 13, 50, 25, 779000)}Print Specific Item where issue is 0 {u'_id': ObjectId('4c73ce215c59731428000000'), u'issue': u'0', u'created': datetime.datetime(2010, 8, 24, 13, 50, 25, 778000)} {u'_id': ObjectId('4c73ce215c59731428000003'), u'issue': u'0', u'location': [34.0, -118.0], u'created': datetime.datetime(2010, 8, 24, 13, 50, 25, 778000)}Print Geo Version where location is near 34.12 and -118.12 {u'_id': ObjectId('4c73ce215c59731428000005'), u'issue': u'2', u'location': [34.0, -118.0], u'created': datetime.datetime(2010, 8, 24, 13, 50, 25, 779000)} {u'_id': ObjectId('4c73ce215c59731428000004'), u'issue': u'1', u'location': [34.0, -118.0], u'created': datetime.datetime(2010, 8, 24, 13, 50, 25, 778000)} {u'_id': ObjectId('4c73ce215c59731428000003'), u'issue': u'0', u'location': [34.0, -118.0], u'created': datetime.datetime(2010, 8, 24, 13, 50, 25, 778000)}Print Specific Item where issue is 0 {u'_id': ObjectId('4c73ce215c59731428000000'), u'issue': u'0', u'created': datetime.datetime(2010, 8, 24, 13, 50, 25, 778000)} {u'_id': ObjectId('4c73ce215c59731428000003'), u'issue': u'0', u'location': [34.0, -118.0], u'created': datetime.datetime(2010, 8, 24, 13, 50, 25, 778000)}Print Geo Sepecic Versions where location is near 34.12 and -118.12 Print Specific Item where issue is 0 {u'_id': ObjectId('4c73ce215c59731428000003'), u'issue': u'0', u'location': [34.0, -118.0], u'created': datetime.datetime(2010, 8, 24, 13, 50, 25, 778000)}Print Everything {u'_id': ObjectId('4c73ce215c59731428000000'), u'issue': u'0', u'created': datetime.datetime(2010, 8, 24, 13, 50, 25, 778000)} {u'_id': ObjectId('4c73ce215c59731428000001'), u'issue': u'1', u'created': datetime.datetime(2010, 8, 24, 13, 50, 25, 778000)} {u'_id': ObjectId('4c73ce215c59731428000002'), u'issue': u'2', u'created': datetime.datetime(2010, 8, 24, 13, 50, 25, 778000)} {u'_id': ObjectId('4c73ce215c59731428000003'), u'issue': u'0', u'location': [34.0, -118.0], u'created': datetime.datetime(2010, 8, 24, 13, 50, 25, 778000)} {u'_id': ObjectId('4c73ce215c59731428000004'), u'issue': u'1', u'location': [34.0, -118.0], u'created': datetime.datetime(2010, 8, 24, 13, 50, 25, 778000)} {u'_id': ObjectId('4c73ce215c59731428000005'), u'issue': u'2', u'location': [34.0, -118.0], u'created': datetime.datetime(2010, 8, 24, 13, 50, 25, 779000)} |
| Comments |
| Comment by auto [ 15/Sep/10 ] |
|
Author: {'login': 'erh', 'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}Message: when using a special index, don't record because may screw up later |
| Comment by auto [ 26/Aug/10 ] |
|
Author: {'login': 'erh', 'name': 'Eliot Horowitz', 'email': 'eliot@10gen.com'}Message: when using a special index, don't record because may screw up later |
| Comment by Sasank Reddy [ 24/Aug/10 ] |
|
I reproduced it on the shell as well. Here it is. Notice the different results you get for > db.mc.find( {'issue':0}) before and after I do the find with the location query. That is the problem. > use mdb > db.mc.ensureIndex( {loc:"2d"}) > db.mc.insert( {'issue':0}) ) ) ) ) ) > db.mc.find() { "_id" : ObjectId("4c73f6cd6a4cdeb8c2f920ff"), "issue" : 0 } { "_id" : ObjectId("4c73f6cf6a4cdeb8c2f92100"), "issue" : 1 } { "_id" : ObjectId("4c73f6d16a4cdeb8c2f92101"), "issue" : 2 } { "_id" : ObjectId("4c73f6f36a4cdeb8c2f92102"), "issue" : 2, "loc" : [ 30.12, -118 ] } { "_id" : ObjectId("4c73f6f86a4cdeb8c2f92103"), "issue" : 1, "loc" : [ 30.12, -118 ] } { "_id" : ObjectId("4c73f6fd6a4cdeb8c2f92104"), "issue" : 0, "loc" : [ 30.12, -118 ] }> db.mc.find( {'issue':0}) { "_id" : ObjectId("4c73f6cd6a4cdeb8c2f920ff"), "issue" : 0 } { "_id" : ObjectId("4c73f6fd6a4cdeb8c2f92104"), "issue" : 0, "loc" : [ 30.12, -118 ] }> db.mc.find({'issue':0,'loc':{$near:[30.12,-118]}}) { "_id" : ObjectId("4c73f6fd6a4cdeb8c2f92104"), "issue" : 0, "loc" : [ 30.12, -118 ] }> db.mc.find( {'issue':0}) { "_id" : ObjectId("4c73f6fd6a4cdeb8c2f92104"), "issue" : 0, "loc" : [ 30.12, -118 ] }> db.mc.find() { "_id" : ObjectId("4c73f6cd6a4cdeb8c2f920ff"), "issue" : 0 } { "_id" : ObjectId("4c73f6cf6a4cdeb8c2f92100"), "issue" : 1 } { "_id" : ObjectId("4c73f6d16a4cdeb8c2f92101"), "issue" : 2 } { "_id" : ObjectId("4c73f6f36a4cdeb8c2f92102"), "issue" : 2, "loc" : [ 30.12, -118 ] } { "_id" : ObjectId("4c73f6f86a4cdeb8c2f92103"), "issue" : 1, "loc" : [ 30.12, -118 ] } { "_id" : ObjectId("4c73f6fd6a4cdeb8c2f92104"), "issue" : 0, "loc" : [ 30.12, -118 ] } |