incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Morton <aa...@thelastpickle.com>
Subject Re: CLUSTERING ORDER CQL3
Date Thu, 12 Dec 2013 03:52:37 GMT
You need to specify all the clustering key components in the CLUSTERING ORDER BY clause 

create table demo(oid int,cid int,ts timeuuid,PRIMARY KEY (oid,cid,ts)) WITH CLUSTERING ORDER
BY (cid ASC, ts DESC);

cheers

-----------------
Aaron Morton
New Zealand
@aaronmorton

Co-Founder & Principal Consultant
Apache Cassandra Consulting
http://www.thelastpickle.com

On 12/12/2013, at 10:44 am, Shrikar archak <shrikar84@gmail.com> wrote:

> Hi All,
> 
> My Usecase
> 
> I want query result by ordered by timestamp DESC. But I don't want timestamp to be the
second column in the primary key as that will take of my querying capability
> 
> for example
> 
> 
> create table demo(oid int,cid int,ts timeuuid,PRIMARY KEY (oid,cid,ts)) WITH CLUSTERING
ORDER BY (ts DESC);
> 
> Queries required:
> 
> 
> I want the result for all the below queries to be in DESC order of timestamp
> 
> select * from demo where oid = 100;
> select * from demo where oid = 100 and cid = 10;
> select * from demo where oid = 100 and cid = 100 and ts > minTimeuuid('something');
> 
> I am trying to create this table with CLUSTERING ORDER IN CQL and getting this error
> 
> 
> cqlsh:viralheat> create table demo(oid int,cid int,ts timeuuid,PRIMARY KEY (oid,cid,ts))
    WITH CLUSTERING ORDER BY (ts desc);
> Bad Request: Missing CLUSTERING ORDER for column cid
> 
> In this document it mentions that we can have multple keys for cluster ordering. any
one know how to do that?
> 
> Go here Datastax doc
> 
> 
> 
> If I make the timestamp the second column then I cant have queries likes 
> 
> 
> select * from demo where oid = 100 and cid = 100 and ts > minTimeuuid('something');
> 
> Thanks,
> 
> Shrikar


Mime
View raw message