Docs Menu

Docs HomePHP Library Manual

MongoDB\Model\IndexInfo::isText()

On this page

  • Definition
  • Return Values
  • Examples
  • See Also

New in version 1.4.

MongoDB\Model\IndexInfo::isText()

Return whether the index is a text index.

function isText(): boolean

A boolean indicating whether the index is a text index.

<?php
$collection = (new MongoDB\Client)->selectCollection('test', 'restaurants');
$collection->createIndex(['name' => 'text']);
foreach ($collection->listIndexes() as $index) {
if ($index->isText()) {
printf("%s has default language: %d\n", $index->getName(), $index['default_language']);
}
}

The output would then resemble:

name_text has default language: english
←  MongoDB\Model\IndexInfo::isSparse()MongoDB\Model\IndexInfo::isTtl() →