incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Decker <decker.christ...@gmail.com>
Subject Creating and using indices
Date Thu, 07 Oct 2010 11:13:18 GMT
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

Mime
View raw message