I'm currently trying to get started on secondary indices in Cassandra
0.7.0svn, but without any luck so far. I have the following code that should
create an index on ColA:

        KsDef ksDef = client.describe_keyspace("MyKeyspace");
>         List<CfDef> cfs = ksDef.cf_defs;
>         String columnFamily = "MyCF";
>         for(CfDef cf : ksDef.cf_defs){
>             if(cf.getName().equals(columnFamily)){
>                 ColumnDef cd1 = new ColumnDef("ColA".getBytes(),
> "org.apache.cassandra.db.marshal.UTF8Type");
>                 cd1.index_type = IndexType.KEYS;
>                 cf.column_metadata.add(cd1);
>                 // Write changes back to DB
>                 client.system_update_column_family(cf);
>             }
>         }
>

which seems to work nicely since when turning up the logging level of
Cassandra it appears to apply some migrations, but then when I try to use a
pycassa client to read an indexed_slice I only get an
InvalidRequestException(why='No indexed columns present in index clause with
operator EQ'):

cf = pycassa.ColumnFamily(client, "MyCF")
> ex = pycassa.index.create_index_expression('ColA', '50000000000000',
> pycassa.index.IndexOperator.LTE)
> clause = pycassa.index.create_index_clause([ex])
> cf.get_indexed_slices(clause)
>

 Am I missing something?

Regards,
Chris

Reply via email to