You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by "Ryabin, Thomas" <Th...@McKesson.com> on 2012/08/20 19:15:36 UTC
How to add secondary index to existing column family with CLI?
I want to add a secondary index to an existing column family, but am running into some trouble. I'm trying to use the Cassandra CLI to add the secondary index. The column family is called "books", the column I'm trying to index is called "title", the key validation class is UTF8Type, and the default column value validator is BytesType.
I first tried running this command with no success:
update column family books with column_metadata=[{column_name: title, index_type: KEYS}];
I got the error:
cannot parse 'title' as hex bytes.
I then tried running:
update column family books with column_metadata=[{column_name: utf8('title'), index_type: KEYS}];
but got the error:
cannot parse 'FUNCTION_CALL' as hex bytes
Is there something I should be doing differently?
Thanks,
Thomas
Re: How to add secondary index to existing column family with CLI?
Posted by aaron morton <aa...@thelastpickle.com>.
The column name must be valid according to the type specified for the comparator .
> cannot parse ‘title’ as hex bytes.
Looks like you dont have a comparator type, so it defaulted to bytes.
You can either change the comparator *IF* all column names are strings or get the ascii code for "title" and use that.
Cheers
-----------------
Aaron Morton
Freelance Developer
@aaronmorton
http://www.thelastpickle.com
On 21/08/2012, at 5:15 AM, "Ryabin, Thomas" <Th...@McKesson.com> wrote:
> I want to add a secondary index to an existing column family, but am running into some trouble. I’m trying to use the Cassandra CLI to add the secondary index. The column family is called “books”, the column I’m trying to index is called “title”, the key validation class is UTF8Type, and the default column value validator is BytesType.
>
> I first tried running this command with no success:
> update column family books with column_metadata=[{column_name: title, index_type: KEYS}];
>
> I got the error:
> cannot parse ‘title’ as hex bytes.
>
>
> I then tried running:
> update column family books with column_metadata=[{column_name: utf8(‘title’), index_type: KEYS}];
>
> but got the error:
> cannot parse ‘FUNCTION_CALL’ as hex bytes
>
>
> Is there something I should be doing differently?
>
> Thanks,
> Thomas
>
>