Make the MongoDB docs better! We value your opinion. Share your feedback for a chance to win $100.
Click here >
Docs Menu
Docs Home
/ /

MongoDB\Model\IndexInfo::is2dSphere()

Nuevo en la versión 1.4.

MongoDB\Model\IndexInfo::is2dSphere()

Devuelve si el índice es un 2dsphere índice.

function is2dSphere(): boolean

Un booleano que indica si el índice es un índice 2dsphere.

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

La vista de salida se ilustraría como sigue:

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

  • MongoDB\Collection::listIndexes()

  • 2Índices dsphere referencia en el manual de MongoDB

Volver

getVersion()

En esta página