Docs Menu

MongoDB\Model\IndexInfo::isSparse()

MongoDB\Model\IndexInfo::isSparse()

Return whether the index is a sparse index. This correlates with the sparse option for MongoDB\Collection::createIndex().

function isSparse(): boolean

A boolean indicating whether the index is a sparse index.

<?php
$info = new IndexInfo([
'sparse' => true,
]);
var_dump($info->isSparse());

The output would then resemble:

bool(true)