MongoDB Geospacial search and official C # driver

Can any expert indicate the best ways to search in geospatial using the official C # driver in MongoDB. The best constructor of objects (strings / doubles), build an index, find next. Many thanks for your help.

db.places.ensureIndex( { loc : "2d" } , { min : -500 , max : 500 } ), db.places.find( { loc : { $near : [50,50] , $maxDistance : 5 } } ).limit(20), 
+6
c # mongodb mongodb-.net-driver
source share
1 answer

C # equivalent to Mongo shell commands:

 places.EnsureIndex(IndexKeys.GeoSpatial("loc"), IndexOptions.SetGeoSpatialRange(-500, 500)); var query = Query.Near("loc", 50, 50, 5); var cursor = places.Find(query).SetLimit(20); foreach (var hit in cursor) { // process hit } 
+8
source share

All Articles