ANNOUNCEMENT: Voyage AI joins MongoDB to power more accurate and trustworthy AI applications on Atlas.
Learn more
Menu Docs

Índice de queda de pesquisa

dropSearchIndex

Novidade na versão 7.0: (Também disponível a partir da versão 6.0.7)

Exclui um índice de Pesquisa do Atlas existente.

O mongosh método fornece um wrapper em torno db.collection.dropSearchIndex() do updateSearchIndex reconhecimento de data center .

Importante

Esse comando só pode ser executado em uma implantação hospedada no MongoDB Atlas e não é suportado em instâncias sem servidor.

Sintaxe do comando:

db.runCommand(
{
dropSearchIndex: "<collection name>",
id: "<index Id>",
name: "<index name>"
}
)

O comando dropSearchIndex usa os seguintes campos:

Campo
Tipo
necessidade
Descrição

dropSearchIndex

string

Obrigatório

Name of the collection that contains the index to delete.

id

string

Condicional

id of the index to delete.

Você deve especificar o campo id ou name .

name

string

Condicional

Name of the index to delete.

Você deve especificar o campo id ou name .

After you run the dropSearchIndex command, there may be a delay between when you receive a response from the command and when the index is deleted.

To see the status of your search indexes, use the $listSearchIndexes aggregation stage. Once your index is deleted, that index no longer appears in the $listSearchIndexes output.

Se a sua implementação impor o controle de acesso, o usuário executando o comando dropSearchIndex deverá ter a ação de privilégio do dropSearchIndex no reconhecimento de data center ou collection:

{
resource: {
db : <database>,
collection: <collection>
},
actions: [ "dropSearchIndex" ]
}

Os papéis embutidos dbAdmin e readWrite fornecem o privilégio do dropSearchIndex . O exemplo a seguir concede a role readWrite no reconhecimento de data center qa :

db.grantRolesToUser(
"<user>",
[ { role: "readWrite", db: "qa" } ]
)

Um comando dropSearchIndex bem-sucedido retorna o seguinte:

{
ok: 1
}

The following example deletes a search index named searchIndex01 on the contacts collection:

db.runCommand( {
dropSearchIndex: "contacts",
name: "searchIndex01"
} )