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

Querying HBase Global Secondary Indexes

Function

Manage HBase global secondary indexes by calling the method in org.apache.hadoop.hbase.hindex.global.GlobalIndexAdmin. listIndices is used for querying indexes, including the definitions and status of all indexes related to the current user table.

Code Sample

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

In this case, all indexes corresponding to the user table user_table are queried.

/**
* List indexes
*/
public void testListIndexes() {
    LOG.info("Entering testListIndexes.");
    try (GlobalIndexAdmin iAdmin = GlobalIndexClient.newIndexAdmin(conn.getAdmin())) {
        for (Pair<HIndexSpecification, IndexState> indexPair : iAdmin.listIndices(tableName)) {
            LOG.info("index spec:{}, index state:{}", indexPair.getFirst(), indexPair.getSecond());
        }
        LOG.info("List indexes successfully.");
    } catch (IOException e) {
        LOG.error("List indexes failed.", e);
    }
    LOG.info("Exiting testListIndexes.");
}