如何在 RethinkDB 中获取所有数据库二级索引的列表

How to get a list of all of a database's secondary indixes in RethinkDB

在 Python 中,如何获取数据库所有二级索引的列表?

例如,在"Tables"下的网络UI中,您可以看到"Secondary indexes"的列表(在本例中只有timestamp);我想在 Python 环境中得到这个。

查看 this 有关 RethinkDB 二级索引的文档。

您可以使用此查询获取 table (e.x. "users") 上所有索引的列表:

r.table("users").index_list()

如果你想获取所有 table 的所有二级索引,你可以查询 table 列表,然后获取每个索引。我不知道 python,但在 Java 脚本中,您可以使用以下查询来完成:

r.tableList().map(function(table){
  return {table: table,
    indexes: r.table(table).indexList()};
})

我认为,在 python 中它看起来像这样:

r.table_list().map(lambda name:{table: name,indexes: r.table(name).index_list()})