Docs 菜单

MongoDB\Model\IndexInfo::isText()

1.4 版本中的新增功能

MongoDB\Model\IndexInfo::isText()

返回该索引是否为文本索引。

function isText(): boolean

指示索引是否为文本索引的布尔值。

<?php
$collection = (new MongoDB\Client)->getCollection('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']);
}
}

而输出将类似如下所示:

name_text has default language: english