You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Manoj Mainali <ma...@gmail.com> on 2013/06/12 08:02:53 UTC

PerRowSecondaryIndex uses

I am looking into the C* secondary index feature so that I could query the
rows based on the column value. In my use case, I wanted to create index of
 several columns or maybe all columns of a row. (A single row does not have
many columns, maybe around 50 - 100 columns) and was looking into
PerRowSecondaryIndex, but I could not find a way to create index using this.

First, C* does not have a default implementation of it like KeysIndex for
PerColumnSecondaryIndex, so I implemented my own. However, I could not find
a way on how I could define it on the client side.

The only way I was able to use it was to define the PerRowSecondaryIndex
class when creating a column index as follows (assuming astyanax client)

ColumnDefinition cd = cluster.makeColumnDefinition();
cd.setName("Index1");
cd.setIndex("INDEX_NAME", "CUSTOM");
cd.setValidationClass("AsciiType");
cd.setOption("class_name",
"org.apache.cassandra.db.index.PerRowSecondaryIndexImpl");
cfDef.addColumnDefinition(cd);

But, this approach would mean although I am creating a index for the whole
row I am doing it through a index creation of a single column.

Is there a better way of creating the row level index? Any examples on how
to do that, if any?

Best regards,

Manoj