如何使用静态列查询cassandra?

如何使用静态列查询cassandra?,cassandra,cassandra-2.0,cassandra-3.0,Cassandra,Cassandra 2.0,Cassandra 3.0,我已将locationtype定义为静态列 我想过滤静态列上的数据 select count(*) from device_stats_by_location where locationtype = "garage"; 但我面临一个例外- InvalidRequest: code=2200 [Invalid query] message="Predicates on non-primary-key columns (locationtype) are not yet supported fo

我已将locationtype定义为静态列

我想过滤静态列上的数据

select count(*) from device_stats_by_location where locationtype = "garage";
但我面临一个例外-

InvalidRequest: code=2200 [Invalid query] message="Predicates on non-primary-key columns (locationtype) are not yet supported for non secondary index queries"
所以尝试

cqlsh:device_data> CREATE INDEX locationtype_indx on device_stats_by_location (locationtype);
生成的错误消息

InvalidRequest: code=2200 [Invalid query] message="Secondary indexes are not allowed on static columns"

我的问题是-如何在CQL查询中使用静态列?

在Cassandra中,您不能使用静态列筛选数据,不能在静态列上创建索引和物化视图。

您可以使用以下任一解决方案

  • 将静态列更改为常规列,并创建索引或物化视图

  • 创建另一个表,并将locationtype设置为分区键,locationid设置为endof10minwindow,devicecategory设置为集群键。无论何时在基表上插入/更新,也要在此表上插入/更新。现在,您可以使用locationtype筛选数据


为什么使用静态列?您的用例是什么?locationtype对于具有相同分区keyData模型=>locationid(Pk)、endof10minwindow(Ck1)、devicecategory(Ck2)、devicecount、locationtype、region(S)的所有行都是固定的=>对于给定的locationid,会有2000行聚集在一起,它们将具有相同的locationtype和region=>这就是为什么将它们指定为static=>按locationtype查询数据的最佳方法是什么?