Updated on 2026-06-29 GMT+08:00

Deleting HBase Global Secondary Indexes

Function

Manage HBase global secondary indexes by calling the method in org.apache.hadoop.hbase.hindex.global.GlobalIndexAdmin. dropIndices is used to delete indexes.

Code Sample

The following code snippets are in the dropIndices method in the GlobalSecondaryIndexSample class of the com.huawei.bigdata.hbase.examples package.

In this case, the idx_id_age index is deleted from the user_table table.

/**
    * dropIndex
    */
public void testDropIndex() {
    LOG.info("Entering testDropIndex.");
    List<String> indexNameList = Lists.newArrayList("idx_id_age");
    // Instantiate HIndexAdmin Object
    try (GlobalIndexAdmin iAdmin = GlobalIndexClient.newIndexAdmin(conn.getAdmin())) {
        // Delete Secondary Index
        iAdmin.dropIndices(tableName, indexNameList);
        LOG.info("Drop index successfully.");
    } catch (IOException e) {
        LOG.error("Drop index failed ", e);
    }
    LOG.info("Exiting testDropIndex.");
}