Navigation
This version of the documentation is archived and no longer supported. To learn how to upgrade your version of PHP Library Manual, refer to the upgrade documentation.

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

<?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