Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-1669

Performing Queries with GeoSpatial Indexes Cause Non-Geospatial results to not return items without location data.

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.7.0
    • Affects Version/s: 1.4.4, 1.6.1
    • Component/s: Geo, Index Maintenance
    • None
    • Environment:
      PyMongo, 1.6.1 and 1.4.4 MongoDB, Ubuntu
    • ALL

      I created a simple python script to test out geospatial indexes which
      is located here: http://pastie.org/1112344 (and also attached)

      Basically, what I'm doing in the script is the following:

      Creating a Geo Index for the "location" field.
      I add three entries which contain issue and created fields (issue
      increases from 0 to 2)
      I add three entries which contain issue, created, and location fields
      (issue increase from 0 to 2)

      1.) I do a find with no query arguments (results are all 6 documents)

      • Pass.
        2.) I do a find where issue is 0 (results are 2 documents - one
        without location, one with location) - Pass.
        3.) I do a find with a location near query (results are 3 documents -
        the three documents with location) - Pass.
        4.) I do a find where issue is 0 (results are 2 documents - one
        without location, one with location) - Pass.
        5.) I do a find with a location near query and where issue is 0
        (results are 1 document - one with location and issue of 0) - Pass.
        6.) I do a find with issue is 0 (results are 1 document - one with
        location) - FAIL - This should of returned the same thing as query 5
        and query 7.
        7.) I do a find with no query arguments (results are all 6 documents)
      • Pass

      What I don't understand is why doing a query with a geo index and
      another parameter causes that parameter not to show up in a non-geo
      index based query. In this case, the query described in (6) results
      in the wrong output. It should also return the document that does not
      have a location field.

      The output of my python program is shown below. Can be reproduced on
      both 1.4.4 and 1.6.1 with PyMongo 1.8.1.


      Create Geo Index for location
      Adding values without location and with 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
      and 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 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)}

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            thecleanmachine Sasank Reddy
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: