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

Cannot use compound of 2d and date value index

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.7.4
    • Component/s: Geo
    • None
    • ALL

      Problem:
      Can't seen to combine $within with additional predicate

      Reproduce:

      > db.testcol.find()
      { "_id" : "1", "title" : "Doc1", "loc" :

      { "lat" : 0, "lng" : 1 }

      , "occurences" : [

      { "instanceId" : 1, "startDate" : ISODate("2001-01-23T03:00:00Z") }

      ,

      { "instanceId" : 2, "startDate" : ISODate("2011-01-30T03:00:00Z") }

      ] }
      { "_id" : "2", "title" : "Doc2", "loc" :

      { "lat" : 0, "lng" : 1 }

      , "occurences" : [

      { "instanceId" : 1, "startDate" : ISODate("2011-01-24T03:00:00Z") }

      ,

      { "instanceId" : 2, "startDate" : ISODate("2011-01-25T03:00:00Z") }

      ] }

      This works

      > db.testcol.find({ "loc": { "$within":
      ...

      { "$box": [ [ 0, 0 ], [ 1, 1 ] ] }

      }
      ... })
      { "_id" : "1", "title" : "Doc1", "loc" :

      { "lat" : 0, "lng" : 1 }

      , "occurences" : [

      { "instanceId" : 1, "startDate" : ISODate("2001-01-23T03:00:00Z") }

      ,

      { "instanceId" : 2, "startDate" : ISODate("2011-01-30T03:00:00Z") }

      ] }
      { "_id" : "2", "title" : "Doc2", "loc" :

      { "lat" : 0, "lng" : 1 }

      , "occurences" : [

      { "instanceId" : 1, "startDate" : ISODate("2011-01-24T03:00:00Z") }

      ,

      { "instanceId" : 2, "startDate" : ISODate("2011-01-25T03:00:00Z") }

      ] }

      However, restricting by occurences.startDate returns no documents

      > db.testcol.find({ "loc": { "$within":
      ...

      { "$box": [ [ 0, 0 ], [ 1, 1 ] ] }

      },
      ... "occurences.startDate":
      ... { "$gte": new Date(2011,0,23)}})

            Assignee:
            greg_10gen Greg Studer
            Reporter:
            alvin Alvin Richards (Inactive)
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: