You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Thorvaldsson Justus <ju...@svenskaspel.se> on 2010/08/17 16:02:31 UTC

How to use Secondary Indices 0.7.0beta1

I figured some but I am stuck, would appreciate help a lot to understand how to use secondary indices.

Create a Column family and define the secondary indices
----"
CfDef cdef = new CfDef();
cdef.setColumn_type(columntype);
cdef.setComment(comment);
cdef.setComparator_type(comparatortype);
cdef.setKey_cache_size(key_cache_size);
cdef.setRow_cache_size(row_cache_size);
cdef.setSubcomparator_type(subcomparatortype);
cdef.setKeyspace(keyspacename);
cdef.setName(columnname);

ColumnDef cd= new ColumnDef();
/*
What pieces of information do I need to set here?
cd.setIndex_name("AnyName?");
cd.setName(<Column byte[] name>?);
there is some more information I can set
validation_class ?
IndexType ?
setFieldValue ?
I am having problems understanding them and don't know if I even need to.
*/

cdef.setColumn_metadata(new ArrayList<ColumnDef>());
cdef.addToColumn_metadata(cd);

system_add_column_family(cdef);
"----
Is this all I need to do to make it work? I am not able to test it because I have one more problem, I don't understand how to set SlicePredicate, KeyRange, SliceRange to search by another index. This is basically API questions and I thought when I figured this out I give it a shot to document how to use it.
Any help is appreciated.
/Justus
AB SVENSKA SPEL
106 10 Stockholm
Sturegatan 11, Sundbyberg
V�xel +46 8 757 77 00
http://svenskaspel.se