You are viewing an offline version of MongoDB documentation. Some page features might be unavailable. To view the latest version of the page or use interactive features, visit the live page.
MongoDB\Model\IndexInfo::isSparse()
Definition
MongoDB\Model\IndexInfo::isSparse()Return whether the index is a sparse index. This correlates with the
sparseoption forMongoDB\Collection::createIndex().function isSparse(): boolean
Return Values
A boolean indicating whether the index is a sparse index.
Examples
$info = new IndexInfo([ 'sparse' => true, ]); var_dump($info->isSparse());
The output would then resemble:
bool(true)
See Also
listIndexes command reference in the MongoDB manual
Sparse Indexes in the MongoDB manual