简体   繁体   中英

how to sort composite columns by column key in cassandra?

In columnfamily, composite column key is (integer, string). I have tried the following comparator_types: 1. CompositeType(IntegerType, AsciiType) 2. CompositeType(IntegerType, BytesType)

I am able to add rows to this columnfamily. But, when i query this columnfamily, columns are not sorted on composite key integer value.

How can i sort all the columns on column key integer? Is comparator_type fine? What's the best way to sort column keys on first part of composite key?

Sorry, the docs say you cannot sort all the columns on your first column key--the integer. First let's clarify terms for folks reading this: A composite column key is the Cassandra storage engine (Thrift/CLI) term for the compound primary key CQL term. http://www.datastax.com/dev/blog/cql3-for-cassandra-experts

The Cassandra 2.0 docs say, "ORDER BY clauses can select a single column only. That column has to be the second column in a compound PRIMARY KEY." http://www.datastax.com/documentation/cql/3.1/cql/cql_reference/select_r.html?scroll=reference_ds_d35_v2q_xj__querying-compound-primary-keys-and-sorting-results

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM