Delete a search index by index name. :param name: The name of the search index to be deleted. :param session: a :class:`~pymongo.client_session.ClientSession`. :param comment: A user-provided comment to attach to this command. :param kwargs: o
(
self,
name: str,
session: Optional[ClientSession] = None,
comment: Optional[Any] = None,
**kwargs: Any,
)
| 2785 | ) |
| 2786 | |
| 2787 | def drop_search_index( |
| 2788 | self, |
| 2789 | name: str, |
| 2790 | session: Optional[ClientSession] = None, |
| 2791 | comment: Optional[Any] = None, |
| 2792 | **kwargs: Any, |
| 2793 | ) -> None: |
| 2794 | """Delete a search index by index name. |
| 2795 | |
| 2796 | :param name: The name of the search index to be deleted. |
| 2797 | :param session: a |
| 2798 | :class:`~pymongo.client_session.ClientSession`. |
| 2799 | :param comment: A user-provided comment to attach to this |
| 2800 | command. |
| 2801 | :param kwargs: optional arguments to the dropSearchIndexes |
| 2802 | command (like maxTimeMS) can be passed as keyword arguments. |
| 2803 | |
| 2804 | .. note:: requires a MongoDB server version 7.0+ Atlas cluster. |
| 2805 | |
| 2806 | .. versionadded:: 4.5 |
| 2807 | """ |
| 2808 | cmd = {"dropSearchIndex": self._name, "name": name} |
| 2809 | cmd.update(kwargs) |
| 2810 | if comment is not None: |
| 2811 | cmd["comment"] = comment |
| 2812 | |
| 2813 | def inner( |
| 2814 | session: Optional[ClientSession], conn: Connection, _retryable_write: bool |
| 2815 | ) -> None: |
| 2816 | self._command( |
| 2817 | conn, |
| 2818 | cmd, |
| 2819 | read_preference=ReadPreference.PRIMARY, |
| 2820 | allowable_errors=["ns not found", 26], |
| 2821 | codec_options=_UNICODE_REPLACE_CODEC_OPTIONS, |
| 2822 | session=session, |
| 2823 | ) |
| 2824 | |
| 2825 | self.database.client._retryable_write(False, inner, session, _Op.DROP_SEARCH_INDEXES) |
| 2826 | |
| 2827 | def update_search_index( |
| 2828 | self, |