========================================
MongoDB\\Collection::updateSearchIndex()
========================================

.. versionadded:: 1.17

.. default-domain:: mongodb

.. contents:: On this page
   :local:
   :backlinks: none
   :depth: 1
   :class: singlecol

Definition
----------

.. phpmethod:: MongoDB\Collection::updateSearchIndex()

   Update an Atlas Search index for the collection.

   .. code-block:: php

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

   .. include:: /includes/extracts/note-atlas-search-requirement.rst

Parameters
----------

``$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
  :manual:`Search Index Definition Syntax </reference/command/createSearchIndexes/#search-index-definition-syntax>`.

``$options`` : array
  An array specifying the desired options.

  .. list-table::
     :header-rows: 1
     :widths: 20 20 80

     * - Name
       - Type
       - Description

     * - comment
       - mixed
       - .. include:: /includes/extracts/common-option-comment.rst

Errors/Exceptions
-----------------

.. include:: /includes/extracts/error-unsupportedexception.rst
.. include:: /includes/extracts/error-invalidargumentexception.rst
.. include:: /includes/extracts/error-driver-runtimeexception.rst

Behavior
--------

.. include:: /includes/extracts/note-atlas-search-async.rst

See Also
--------

- :phpmethod:`MongoDB\Collection::createSearchIndex()`
- :phpmethod:`MongoDB\Collection::createSearchIndexes()`
- :phpmethod:`MongoDB\Collection::dropSearchIndex()`
- :phpmethod:`MongoDB\Collection::listSearchIndexes()`
- :manual:`updateSearchIndex </reference/command/updateSearchIndex>` command
  reference in the MongoDB manual
- `Atlas Search <https://www.mongodb.com/docs/atlas/atlas-search/>`__ documentation in the MongoDB Manual
