Cassandra:根据LIKE或CONTAINS等限制列出键空间中的所有表?

Cassandra: List all tables in keyspace based on restriction such as LIKE or CONTAINS?

每个键空间有很多 table,因此我想根据限制条件过滤 table。我试过这个查询,但它并没有真正给出我想要的预期结果:

SELECT table_name FROM system_schema.tables 
WHERE keyspace_name = 'test' 
and table_name >= 'test_001_%';

显示的输出是:

'table_name'
---------------------
 'test_001_metadata'    
 'test_001_time1'    
 'test_001_time2'    
 'test_001_time3'    
 'test_001_time4'    
 'test_002_metadata'    
 'test_002_time1'    
 'test_002_time2'
 'test_002_time3'

我真正想要的是: 显示的输出是:

'table_name'
---------------------
 'test_001_metadata'    
 'test_001_time1'    
 'test_001_time2'    
 'test_001_time3'    
 'test_001_time4'   

另一种方法是通过在 table_name 上创建二级索引来使用 LIKE 关键字。但我有点怀疑它是否会引起问题,因为它是一个系统 table。另一个问题是,聚类列实际上是否支持二级索引?

在删除之前的索引后,在 table_name 列上创建模式包含的 SASI 索引,并尝试使用

进行查询
SELECT table_name FROM system_schema.tables 
WHERE keyspace_name = 'test' 
and table_name LIKE '%test_001_%';

创建模式为contains的SASI索引的命令如下:

CREATE CUSTOM INDEX ON system_schema.tables(table_name) 
USING 'org.apache.cassandra.index.sasi.SASIIndex' 
WITH OPTIONS = {'analyzer_class': 'org.apache.cassandra.index.sasi.analyzer.StandardAnalyzer', 
'case_sensitive': 'false', 'tokenization_normalize_uppercase': 'true', 'mode': 'CONTAINS'} 

对于你的第二个问题,你不能在属于 PRIMARY KEY 的任何内容上创建二级索引。