【发布时间】:2019-02-14 12:47:02
【问题描述】:
我们有一张桌子:
CREATE TABLE table (
col1 text,
col2 text,
col3 timestamp,
cl4 int,
col5 timestamp,
PRIMARY KEY (col1, col2, col3, col4)
) WITH CLUSTERING ORDER BY (col2 DESC, col3 DESC,col4 DESC)
当我尝试从这个表中查询时:
select * from table where col1 = 'something' and col3 < 'something'
and col4= 12 limit 5 ALLOW FILTERING;
select * from table where col1 = 'something' and col4 < 23
and col3 >= 'something' ALLOW FILTERING;
我总是得到错误:Clustering column "col4" cannot be restricted (preceding column "col3" is restricted by a non-EQ relation)。
我尝试通过创建 col4、col3、col2 来更改表创建,但第二个查询不起作用并引发类似错误。
解决此问题的任何建议/建议。
我们正在:Cassandra 3.0.17.7。
【问题讨论】:
-
请阅读 - ClusteringColumns
-
如果您的查询不打算使用
col2,那么为什么要将它作为集群列呢?将其从您的 PRIMARY KEY def 中取出(或使其成为最后一个聚类列),然后您就不需要ALLOW FILTERING。