The DROP INDEX statement allows you to drop a named primary index or a secondary index. Dropping an index that has replicas will also drop all of the replica indexes too. You can drop unnamed primary indexes using the DROP PRIMARY INDEX statement.
User executing the DROP INDEX statement must have the Query Manage Index privilege granted on the keyspace/bucket. For more details about user roles, see Authorization.
drop-index ::= DROP INDEX index-path [ index-using ]
index-path ::= [ namespace ':' ] keyspace '.' index-name
(Optional) An identifier that refers to the namespace of the indexed keyspace. Currently, only the
defaultnamespace is available. If the namespace name is omitted, the default namespace in the current session is used.
(Required) An identifier that refers to the bucket name or keyspace. It specifies the bucket as the source for the index which needs to be deleted.
(Required) A unique name that identifies the index.
default:`travel-sample`.`def-type` indicates the
def-type index in the
travel-sample keyspace in the
|If there is a hyphen (-) inside the keyspace or index name, you must wrap it in backticks (` `).|
When using memory-optimized indexes, DROP INDEX is an expensive operation and may take a few minutes to complete.
If you drop an index with replicas while one of the index nodes is failed over, then only the replicas in the active index nodes are dropped. If the failed-over index node is recovered, then the orphan replica will be dropped when this failed-over indexer is added back to cluster.
If you drop an index with replicas when one of the index nodes is unavailable but not failed over, the drop index operation may fail.
|We recommend that you do not drop (or create) secondary indexes when any node with a secondary index role is down as this may result in duplicate index names.|
This example creates a secondary index on the travel-sample bucket. Once the index creation statement comes back, system:indexes is queried for status of the index.
CREATE INDEX `idx-callsign` ON `travel-sample`(callsign) USING GSI; SELECT * FROM system:indexes WHERE name="idx-callsign";
Subsequently, the index is dropped with the following statement and it no longer is reported in the system:indexes output.
DROP INDEX `travel-sample`.`idx-callsign` USING GSI; SELECT * FROM system:indexes WHERE name="idx-callsign";