1.4版本新增。:
定义
MongoDB\Model\IndexInfo::is2dSphere()返回该索引是否为2 dsphere索引。
function is2dSphere(): boolean
Return Values
指示索引是否为 2dsphere 索引的布尔值。
示例
$collection = (new MongoDB\Client)->getCollection('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
另请参阅
MongoDB手册中的2 dsphere 索引参考