Reputation: 11
We have a table:
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)
When I try querying from this table like:
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;
I always get the error: Clustering column "col4" cannot be restricted (preceding column "col3" is restricted by a non-EQ relation)
.
I tried to change the table creation by making col4, col3, col2, but the second query doesn't work and throw a similar error.
Any suggetion/advice to solve this problem.
We are on : Cassandra 3.0.17.7.
Upvotes: 1
Views: 120
Reputation: 87329
You can use non-equality condition only on the last column of partition of the query.
For example, you can do use col1 = val and col2 <= ...
, or col1 = val and col2 = val2 and col3 <= ...
, or col1 = val and col2 = val2 and col3 = val3 and col4 <= ...
, but you can't do non-equality condition on several columns - that's how Cassandra reads data.
Upvotes: 1