简体   繁体   中英

How can I query cli query in Cassandra by composite key?

I create the following Column Family in Cassandra:

  CREATE COLUMN FAMILY test with comparator = 'CompositeType(UTF8Type,UTF8Type)' and key_validation_class=UTF8Type;

Now I want to add some data:

set test['a']['b:c'] = 'abc'
set test['a']['b:d'] = 'abd'
set test['a']['e:f'] = 'aef'
set test['a']['e:g'] = 'aeg';

Now I would like to retrieve all rows which have e in its Composite key:

something like:

 get test['a']['e:*];

and result should be 'aef' and 'aeg'.

How cli query should look like?

I am not sure about CQL, but with playOrm, if you partitioned by a, you can just do S-SQL(scalable SQL) query of

PARTITIONS alias('a') SELECT alias FROM Table as alias WHERE a.column = 'e';

A partition can have millions of rows.

Anyways, just thought it might help you a bit.

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