文档菜单
文档首页
/ / /
PHP 库手册
/ / /

MongoDB\Model\IndexInfo::is2dSphere()

本页内容

  • 定义
  • 返回值
  • 示例
  • 另请参阅

新增在版本1.4.

MongoDB\Model\IndexInfo::is2dSphere()

返回索引是否为2dsphere 索引。

function is2dSphere(): boolean

一个布尔值,表示索引是否为2dsphere索引。

<?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']);
}
}

输出将类似于

pos_2dsphere has 2dsphereIndexVersion: 3
  • MongoDB\Collection::createIndex()

  • MongoDB\Collection::listIndexes()

  • 2dsphere索引 参考MongoDB手册

返回

getVersion()