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

$geoWithin does not return results

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 2.6.0-rc0
    • Geo
    • 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]]]}}}} );  

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: