Cql3 with more than 1 EQ and ORDER BY constraint

using CF:

CREATE TABLE history ( domain text, iid text, timeid timeuuid, data text, comments text, PRIMARY KEY (domain, iid, timeid) ); 

I would like to request it like this:

 select domain, iid, timeid, data, comments from mappings where domain = 'a' and iid = 'b' order by timeid desc; 

But it fails with the following error (cassandra 1.1.5):

 Bad Request: Order by currently only support the ordering of columns following their declared order in the PRIMARY KEY 

Am I doing it wrong? What could be the workaround? thanks

PS I got the job with a single EQ and ORDER BY constraint, but I need at least 2 constraints and an order.

+8
cassandra cql3
source share
1 answer

In the first column of the primary key, you can change the column "in order":

select * from history where domain = 'a' and iid = 'b' order by iid desc;

This is a bit confusing because you limit iid equality, but it works - you get a result sorted by timeid .

I believe this is because iid and timeid form one composite column, and when you order iid in descending order, it orders all the composite components of the column, including timeid .

+9
source share

All Articles