incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yuhan Zhang <yzh...@onescreen.com>
Subject cassandra secondary index with
Date Tue, 19 Jun 2012 19:23:37 GMT
Hi all,

I'm trying to search by the secondary index of cassandra with "greater than
or equal". but reached an exception stating:
me.prettyprint.hector.api.exceptions.HInvalidRequestException:
InvalidRequestException(why:No indexed columns present in index clause with
operator EQ)

However, the same column family with the same column, work when the search
expression is an "equal". I'm using the Hector java client.
The secondary index type has been set to: {column_name: sport,
validation_class: DoubleType, index_type:KEYS }

here's the code reaching the exception:

public QueryResult<OrderedRows<String, String, Double>>
getIndexedSlicesGTE(String columnFamily, String columnName, double value,
String... columns) {
        Keyspace keyspace = getKeyspace();
        StringSerializer se = CassandraStorage.getStringExtractor();

        IndexedSlicesQuery<String, String, Double> indexedSlicesQuery =
createIndexedSlicesQuery(keyspace, se, se, DoubleSerializer.get());
        indexedSlicesQuery.setColumnFamily(columnFamily);
        indexedSlicesQuery.setStartKey("");
        if(columns != null)
            indexedSlicesQuery.setColumnNames(columns);
        else {
            indexedSlicesQuery.setRange("", "", true, MAX_RECORD_NUMBER);
        }
        indexedSlicesQuery.setRowCount(CassandraStorage.MAX_RECORD_NUMBER);
        indexedSlicesQuery.addGteExpression(columnName, value);
// this doesn't work :(
        //indexedSlicesQuery.addEqualsExpression(columnName, value);    //
this works!
        QueryResult<OrderedRows<String, String, Double>> result =
indexedSlicesQuery.execute();

        return result;
    }


Is there any column_meta setting that is required in order to make GTE
comparison works on secondary index?

Thank you.

Yuhan Zhang

Mime
View raw message