cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Petr Odut <petr.o...@gmail.com>
Subject Re: Creating and using indices
Date Thu, 07 Oct 2010 14:57:05 GMT
What I've tested you must include at least one expression with EQ operator

On Thu, Oct 7, 2010 at 3:45 PM, Matthew Dennis <mdennis@riptano.com> wrote:

> If I remember correctly the only operator supported for secondary indexes
> right now is EQ, not LTE (or the others).
>
>
> On Thu, Oct 7, 2010 at 6:13 AM, Christian Decker <
> decker.christian@gmail.com> wrote:
>
>> 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
>>
>
>
>
> --
> Riptano
> Software and Support for Apache Cassandra
> http://www.riptano.com/
> mdennis@riptano.com
> m: 512.587.0900 f: 866.583.2068

Mime
View raw message