You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Jim Ancona <ji...@anconafamily.com> on 2011/10/05 22:08:51 UTC

cassandra-cli: Create column family with composite column name

Using Cassandra 0.8.6, I've been trying to figure out how to use the
CLI to create column families using composite keys and column names.
The documentation on CompositeType seems pretty skimpy. But in the
course of writing this email to ask how to do it, I figured out the
proper syntax. In the hope of making it easier for the next person, I
repurposed this message to document what I figured out. I'll also
update the wiki. Here is the syntax:

create column family MyCF
    with key_validation_class = 'CompositeType(UTF8Type, IntegerType)'
    and comparator = 'CompositeType(DateType(reversed=true), UTF8Type)'
    and default_validation_class='CompositeType(UTF8Type, DateType)'
    and column_metadata=[
        { column_name:'0:my Column Name', validation_class:LongType,
index_type:KEYS}
    ];

One weakness of this syntax is that there doesn't seem to be a way to
escape a ':' in a composite value. There's a FIXME in the code to that
effect.

Jim

Re: cassandra-cli: Create column family with composite column name

Posted by aaron morton <aa...@thelastpickle.com>.
Hi Jim, 

The best resource I know so far is http://www.slideshare.net/edanuff/indexing-in-cassandra  

I just started working on a blog post about them last night, and I hope to update the wiki with some information when I am done. Feel free to mail me directly if you want to collaborate. 

I'm none the wiser on the ":" issue, one of the things I was hoping to learn about. 

Cheers

-----------------
Aaron Morton
Freelance Cassandra Developer
@aaronmorton
http://www.thelastpickle.com

On 6/10/2011, at 9:08 AM, Jim Ancona wrote:

> Using Cassandra 0.8.6, I've been trying to figure out how to use the
> CLI to create column families using composite keys and column names.
> The documentation on CompositeType seems pretty skimpy. But in the
> course of writing this email to ask how to do it, I figured out the
> proper syntax. In the hope of making it easier for the next person, I
> repurposed this message to document what I figured out. I'll also
> update the wiki. Here is the syntax:
> 
> create column family MyCF
>    with key_validation_class = 'CompositeType(UTF8Type, IntegerType)'
>    and comparator = 'CompositeType(DateType(reversed=true), UTF8Type)'
>    and default_validation_class='CompositeType(UTF8Type, DateType)'
>    and column_metadata=[
>        { column_name:'0:my Column Name', validation_class:LongType,
> index_type:KEYS}
>    ];
> 
> One weakness of this syntax is that there doesn't seem to be a way to
> escape a ':' in a composite value. There's a FIXME in the code to that
> effect.
> 
> Jim