1
votes

Hector: hector-core-1.0-5 Cassandra-1.1.2

I need to model a query in Hector like:

select * from table1 where rowkey='x' and secondary_indexed_column='y'

If I use an IndexedSliceQuery with setStartKey set to rowKey 'x', I still get all rows containing secondary_indexed_column='y'. If I add the row_key field in addEqualsExpression("row_key",'x'), I get the following exception:

org.apache.thrift.protocol.TProtocolException: Required field 'value' was not present! Struct: IndexExpression(column_name:64 65 76 69 63 65 5F 69 64, op:EQ, value:null)
    at org.apache.cassandra.thrift.IndexExpression.validate(IndexExpression.java:562)
    at org.apache.cassandra.thrift.IndexExpression.write(IndexExpression.java:499)
    at org.apache.cassandra.thrift.IndexClause.write(IndexClause.java:521)
    at org.apache.cassandra.thrift.Cassandra$get_indexed_slices_args.write(Cassandra.java:13469)
    at org.apache.cassandra.thrift.Cassandra$Client.send_get_indexed_slices(Cassandra.java:793)
    at org.apache.cassandra.thrift.Cassandra$Client.get_indexed_slices(Cassandra.java:781)
    at me.prettyprint.cassandra.service.KeyspaceServiceImpl$19.execute(KeyspaceServiceImpl.java:732)

So, how do I restrict my indexedSliceQuery to return the result only for the given row key?

1
So, I'm a little confused. You are supplying the row key that you wish to search for a specific column? You don't need an index for that, just read the row and check for the column name & value. IndexedSliceQuery will return a set of rows (at specified start point) which contain the specified column name/value. - libjack

1 Answers

0
votes

Another option is if you have partitioned data, you can do this query in playOrm which supports millions of rows in a partition(do not exceed 10 million though) and as many partitions as you want in a table. Then you just do the query

@NoSqlQuery(name="findSomething", query="PARTITIONS t(:partitionId) SELECT t FROM TABLE as t WHERE date > :some and yyyy < :second")

NOTE: notice there is NO limitiation on the query except it is within a partition AND you can do JOINS as well!!!!