Return-Path: Delivered-To: apmail-cassandra-user-archive@www.apache.org Received: (qmail 2182 invoked from network); 7 Oct 2010 13:46:09 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 7 Oct 2010 13:46:09 -0000 Received: (qmail 20517 invoked by uid 500); 7 Oct 2010 13:46:08 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 20464 invoked by uid 500); 7 Oct 2010 13:46:06 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 20456 invoked by uid 99); 7 Oct 2010 13:46:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Oct 2010 13:46:05 +0000 X-ASF-Spam-Status: No, hits=2.9 required=10.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.215.44] (HELO mail-ew0-f44.google.com) (209.85.215.44) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Oct 2010 13:45:59 +0000 Received: by ewy21 with SMTP id 21so268418ewy.31 for ; Thu, 07 Oct 2010 06:45:37 -0700 (PDT) MIME-Version: 1.0 Received: by 10.213.28.205 with SMTP id n13mr1583744ebc.5.1286459132954; Thu, 07 Oct 2010 06:45:32 -0700 (PDT) Received: by 10.14.29.66 with HTTP; Thu, 7 Oct 2010 06:45:32 -0700 (PDT) X-Originating-IP: [108.117.88.249] In-Reply-To: References: Date: Thu, 7 Oct 2010 08:45:32 -0500 Message-ID: Subject: Re: Creating and using indices From: Matthew Dennis To: user@cassandra.apache.org Content-Type: multipart/alternative; boundary=0015174c3960a347c00492071b8e --0015174c3960a347c00492071b8e Content-Type: text/plain; charset=ISO-8859-1 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 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 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 --0015174c3960a347c00492071b8e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable If I remember correctly the only operator supported for secondary indexes r= ight 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 with= out any luck so far. I have the following code that should create an index = on ColA:

=A0=A0=A0 =A0=A0=A0 KsDef ksDef =3D client.describe_keyspace("MyKeyspa= ce");
=A0=A0=A0 =A0=A0=A0 List<CfDef> cfs =3D ksDef.cf_defs;<= br>=A0=A0=A0 =A0=A0=A0 String columnFamily =3D "MyCF";
=A0=A0= =A0 =A0=A0=A0 for(CfDef cf : ksDef.cf_defs){
=A0=A0=A0 =A0=A0=A0 =A0=A0= =A0 if(cf.getName().equals(columnFamily)){
=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 ColumnDef cd1 =3D new ColumnDef(&qu= ot;ColA".getBytes(), "org.apache.cassandra.db.marshal.UTF8Type&qu= ot;);
=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 cd1.index_type =3D IndexTy= pe.KEYS;
=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 cf.column_metadata.add(= cd1);
=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 // Write changes back to DB
=A0= =A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 client.system_update_column_family(cf)= ;
=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 }
=A0=A0=A0 =A0=A0=A0 }

which seems to work nicely since when turning up the logging le= vel of Cassandra it appears to apply some migrations, but then when I try t= o use a pycassa client to read an indexed_slice I only get an InvalidReques= tException(why=3D'No indexed columns present in index clause with opera= tor EQ'):

cf =3D pycass= a.ColumnFamily(client, "MyCF")
ex =3D pycassa.index.create_ind= ex_expression('ColA', '50000000000000', pycassa.index.Index= Operator.LTE)
clause =3D pycassa.index.create_index_clause([ex])
cf.get_indexed_slices= (clause)

=A0Am 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
--0015174c3960a347c00492071b8e--