Menu Docs
Página inicial do Docs
/ /
Classe IndexInfo

MongoDB\Model\IndexInfo::isGeoHaystack()

Novidade na versão 1.4.

Descontinuado desde a versão 1.16: MongoDB 5.0 e posterior não suportam mais índices geoHaystack.

MongoDB\Model\IndexInfo::isGeoHaystack()

Retorna se o índice é um índicegeoHaystack .

function isGeoHaystack(): boolean

Um booleano que indica se o índice é um índice geoHaystack.

<?php
$collection = (new MongoDB\Client)->selectCollection('test', 'places');
$collection->createIndex(['pos' => 'geoHaystack', 'x' => 1], ['bucketSize' => 5]);
foreach ($collection->listIndexes() as $index) {
if ($index->isGeoHaystack()) {
printf("%s has bucketSize: %d\n", $index->getName(), $index['bucketSize']);
}
}

A saída seria então semelhante a:

pos_geoHaystack_x_1 has bucketSize: 5
  • MongoDB\Collection::createIndex()

  • MongoDB\Collection::listIndexes()

  • Referência de índices geoHaystack no manual MongoDB

Nesta página