Docs Menu
Docs Home
/ / /
PHP Library Manual
/ /


On this page

  • Definition
  • Parameters
  • Errors/Exceptions
  • Behavior
  • See Also

New in version 1.17.


Update an Atlas Search index for the collection.

function updateSearchIndex(
string $name,
array|object $definition,
array $options = []
): void

This command can only be run on a deployment hosted on MongoDB Atlas and requires an Atlas cluster tier of at least M10. A Local Atlas Deployment can also be used for development.

$name : string
Name of the index to update.
$definition : array|object
Document describing the updated search index definition. The specified definition replaces the prior definition in the search index. For details on definition syntax, see Search Index Definition Syntax.
$options : array

An array specifying the desired options.


Enables users to specify an arbitrary comment to help trace the operation through the database profiler, currentOp output, and logs.

MongoDB\Exception\UnsupportedException if options are used and not supported by the selected server (e.g. collation, readConcern, writeConcern).

MongoDB\Exception\InvalidArgumentException for errors related to the parsing of parameters or options.

MongoDB\Driver\Exception\RuntimeException for other errors at the extension level (e.g. connection errors).

Atlas Search indexes are managed asynchronously. After creating or updating an index, you can periodically execute MongoDB\Collection::listSearchIndexes() and check the queryable output field to determine whether it is ready to be used.

← updateOne()
watch() →