1.4版本新增。
定义
MongoDB\Model\IndexInfo::is2dSphere()Return whether the index is a 2dsphere index.
function is2dSphere(): boolean
Return Values
指示索引是否为 2dsphere 索引的布尔值。
示例
$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']); } }
而输出将类似如下所示:
pos_2dsphere has 2dsphereIndexVersion: 3
另请参阅
2dsphere Indexes reference in the MongoDB manual