6

I need to be able to perform search on secondary indexes using only <, >, <=, or >=. I understand that Cassandra requires at least one equality index clause because it iterates over all the results from that equality index.

Are there any tricks to perform operations using only <, >, <=, or >= (at least conceptually)? Is it a bad idea?

Also, does anybody know if there are any plans to change this in Cassandra?

Thanks!

David V
  • 11,531
  • 5
  • 42
  • 66

1 Answers1

6

If there were a good way to do this with 0.7 indexes, we/I would have mentioned it in http://www.datastax.com/dev/blog/whats-new-cassandra-07-secondary-indexes instead of saying "you need an equality expression." There is no Double Secret Cheat Code.

One alternative is to use ByteOrderedPartitioner (which lets you do >= queries on the row key). Another may be to create a materialized view on some subset of your data at write time. That's assuming you have enough rows that simply doing an unordered sequential scan is too slow.

Bitmap indexes in 0.8 ( https://issues.apache.org/jira/browse/CASSANDRA-1472) will support inequality operations on indexes.

jbellis
  • 19,347
  • 2
  • 38
  • 47
  • see also https://issues.apache.org/jira/browse/CASSANDRA-1339. Note also that as of this writing, 0.8 has been released and the feature is not yet present, and on the issue tracker, the last comment to 1472 was ~3 months ago and the last patch posted was ~9 months ago. (i am not a Cassandra dev and jbellis is, i'm just a potential user trying to estimate when this feature will be available) – bshanks Sep 18 '11 at 20:08