Articles → MONGODB → $Centersphere Operator In Mongodb
$Centersphere Operator In Mongodb
Purpose
Syntax
{
$geoWithin: {
$centerSphere: [ [ <x>, <y> ], <radius> ]
}
}
Creating The 2Dsphere Index
db.locations.createIndex({ location: "2dsphere" });
Example
db.locations.find({
location: {
$geoWithin: {
$centerSphere: [ [ 77.2441, 28.6189 ], 4 / 6378.1 ]
}
}
});
Output