Docs Menu

Docs HomePHP Library Manual

MongoDB\Model\IndexInfo::isGeoHaystack()

On this page

  • Definition
  • Return Values
  • Examples
  • See Also

New in version 1.4.

Deprecated since version 1.16: MongoDB 5.0 and later no longer supports geoHaystack indexes.

MongoDB\Model\IndexInfo::isGeoHaystack()

Return whether the index is a geoHaystack index.

function isGeoHaystack(): boolean

A boolean indicating whether the index is a geoHaystack index.

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

The output would then resemble:

pos_geoHaystack_x_1 has bucketSize: 5
←  MongoDB\Model\IndexInfo::is2dSphere()MongoDB\Model\IndexInfo::isSparse() →