MongoDB\Model\IndexInfo::is2dSphere()
On this page
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