如何使用静态列查询cassandra?
我已将locationtype定义为静态列 我想过滤静态列上的数据如何使用静态列查询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
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筛选数据