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

$geoWithin does not return results

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.0-rc0
    • Component/s: Geo
    • Labels:
      None
    • ALL
    • Hide
      db.createCollection( "testGeoWithin" );
      
      db.testGeoWithin.insert(
      {
              "geometry" : {
                      "location" : {
                              "lng" : -73.771799,
                              "lat" : 41.033431
                      }
              },
              "types" : [
                      "school",
                      "establishment"
              ]
      } );
      
      
      db.testGeoWithin.ensureIndex( {"geometry.location" : "2d" } );
      
      db.testGeoWithin.find( {"types":{"$in":["school"]},"geometry":{"$geoWithin":{"$geometry":{"type":"Polygon","coordinates":[[[-73.765358810837,41.036711084713],[-73.773316461021,41.036711084713],[-73.773316461021,41.031802162346],[-73.765358810837,41.031802162346],[-73.765358810837,41.036711084713]]]}}}} );
      
      
      Show
      db.createCollection( "testGeoWithin" ); db.testGeoWithin.insert( { "geometry" : { "location" : { "lng" : -73.771799, "lat" : 41.033431 } }, "types" : [ "school" , "establishment" ] } ); db.testGeoWithin.ensureIndex( { "geometry.location" : "2d" } ); db.testGeoWithin.find( { "types" :{ "$ in " :[ "school" ]}, "geometry" :{ "$geoWithin" :{ "$geometry" :{ "type" : "Polygon" , "coordinates" :[[[-73.765358810837,41.036711084713],[-73.773316461021,41.036711084713],[-73.773316461021,41.031802162346],[-73.765358810837,41.031802162346],[-73.765358810837,41.036711084713]]]}}}} );

      db.testGeoWithin.insert(
      {
              "geometry" : {
                      "location" : {
                              "lng" : -73.771799,
                              "lat" : 41.033431
                      }
              },
              "types" : [
                      "school",
                      "establishment"
              ]
      } );
      
      db.testGeoWithin.ensureIndex( {"geometry.location" : "2d" } );
      
      db.testGeoWithin.find( {"types":{"$in":["school"]},"geometry":{"$geoWithin":{"$geometry":{"type":"Polygon","coordinates":[[[-73.765358810837,41.036711084713],[-73.773316461021,41.036711084713],[-73.773316461021,41.031802162346],[-73.765358810837,41.031802162346],[-73.765358810837,41.036711084713]]]}}}} );
      

      Should return the inserted doc.
      Btw, it works just fine in 2.4.6.

        1. server12987.js
          1 kB
          Benety Goh

            Assignee:
            benety.goh@mongodb.com Benety Goh
            Reporter:
            rookie7799 Pavel Baranov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: