You are viewing an offline version of MongoDB documentation. Some page features might be unavailable. To view the latest version of the page or use interactive features, visit the live page.
MongoDB\Model\IndexInfo::is2dSphere()
New in version 1.4.
Definition
MongoDB\Model\IndexInfo::is2dSphere()Return whether the index is a 2dsphere index.
function is2dSphere(): boolean
Return Values
A boolean indicating whether the index is a 2dsphere index.
Examples
$collection = (new MongoDB\Client)->selectCollection('test', 'places'); $collection->createIndex(['pos' => '2dsphere']); foreach ($collection->listIndexes() as $index) { if ($index->is2dSphere()) { printf("%s has 2dsphereIndexVersion: %d\n", $index->getName(), $index['2dsphereIndexVersion']); } }
The output would then resemble:
pos_2dsphere has 2dsphereIndexVersion: 3
See Also
2dsphere Indexes reference in the MongoDB manual