Docs Menu
Docs Home
/ / /
PHP Library Manual
/ / /

MongoDB\Model\IndexInfo::is2dSphere()

On this page

  • Definition
  • Return Values
  • Examples
  • See Also

New in version 1.4.

MongoDB\Model\IndexInfo::is2dSphere()

Return whether the index is a 2dsphere index.

function is2dSphere(): boolean

A boolean indicating whether the index is a 2dsphere index.

<?php
$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
  • MongoDB\Collection::createIndex()

  • MongoDB\Collection::listIndexes()

  • 2dsphere Indexes reference in the MongoDB manual

Back

getVersion()