---
title: 查看已创建的索引
description: "listIndices API用于查看索引信息，调用接口查询已存在的索引的相关信息。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/2300/bds/kunpengbds_omniruntime_20_0210.html
sourcePath: /source/zh/kunpengboostkithistory/2300/bds/kunpengbds_omniruntime_20_0210.html
indexId: b790d636116e8cca688a4f3dcd059087e08c6e2807a607cf315ace0ca88cb54e78
---
# 查看已创建的索引

listIndices API用于查看索引信息，调用接口查询已存在的索引的相关信息。

#### listIndices API

- listIndices API

```
void listIndices(TableName tableName)
```


- 功能描述
  客户端查询索引请求接口，用于返回给定数据表所有索引表的相关信息。

- API描述

  1. 包名：package com.huawei.boostkit.hindex
  2. 类名：GlobalIndexAdmin
  3. 方法名：listIndices
  4. 参数详情：| 参数名称 | 取值类型 | 描述 |
| --- | --- | --- |
| tableName | TableName | 用户数据表 |


- 使用样例

```
//创建用户表myuser，并添加数据
Admin admin = connection.getAdmin();
TableName myuser = TableName.valueOf("myuser");
HTableDescriptor hTableDescriptor = new HTableDescriptor(myuser);
HColumnDescriptor f1 = new HColumnDescriptor("f1");
hTableDescriptor.addFamily(f1);
admin.createTable(hTableDescriptor);
try (Table table = conn.getTable(myuser)) {
Put put0 = new Put(Bytes.toBytes("001"));
put0.addColumn(Bytes.toBytes("f1"), Bytes.toBytes("q1"), Bytes.toBytes("test"));
table.put(ImmutableList.of(put0));
}
//创建索引表myindex
TableIndices myindex = new TableIndices();
HIndexSpecification spec = new HIndexSpecification("myindex");
//对数据表f1列族的q1创建索引，数据类型是STRING
spec.addIndexColumn(Bytes.toBytes("f1"), Bytes.toBytes("q1"), ValueType.STRING);
myindex.addIndex(spec);
GlobalIndexAdmin globalIndexAdmin = GlobalIndexClient.newIndexAdmin(admin);
globalIndexAdmin.addIndicesWithData(myuser, myindex);
// 查看myuser所有的索引表
List<Pair<HIndexSpecification, IndexState>> indices = globalIndexAdmin.listIndices(myuser);
```


- 样例结果
  以列表的方式返回myuser所有索引表。
