Cassandra选择查询失败

问题描述 投票:1回答:1

我们有一张桌子:

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。

cassandra cassandra-3.0
1个回答
1
投票

您只能在查询的最后一列分区上使用非相等条件。

例如,您可以使用col1 = val and col2 <= ...,或col1 = val and col2 = val2 and col3 <= ...col1 = val and col2 = val2 and col3 = val3 and col4 <= ...,但您不能在多个列上执行不相等条件 - 这就是Cassandra读取数据的方式。

© www.soinside.com 2019 - 2024. All rights reserved.