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

$box should be able to use a 2dsphere query if available and valid coords

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Minor - P4
    • Resolution: Works as Designed
    • 2.5.5
    • None
    • Geo
    • None

    Description

      In the following test case - I'd expect the $box query to be able to use the 2dsphere index rather than just a basic cursor.

      db.geo.drop()
      db.geo.insert( { type: "house", loc : { type : "Point", coordinates : [ 71.0603, 42.3583 ] } })
      db.geo.insert( { type: "flat",  loc : { type : "Point", coordinates : [ 87.6500, 41.8500 ] } })
       
      db.geo.ensureIndex({loc: "2dsphere", type: 1});
       
      // Query using $box
      db.geo.find({loc: {
          $geoWithin: {
              $box: [[-180, -90], [180, 90]]
          }
      }, type: "house"}).explain()

      Essentially the query is the same as - which will use the 2dsphere index

      db.geo.find( { loc :
        { $geoWithin :
          { $geometry :
            { type : "Polygon" ,
              coordinates : [[ [-180, -90], [180, -90], [180, 90], [-180, -90] ] ]
        } } },
        type: "house" } ).explain()

      Attachments

        Activity

          People

            Unassigned Unassigned
            ross@mongodb.com Ross Lawley
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: