Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 672
danny.lesnik Avatar asked Nov 03 '22 15:11

danny.lesnik


1 Answers

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.

like image 83
Dean Hiller Avatar answered Nov 14 '22 03:11

Dean Hiller