How to search secondary index in Cassandra without equality?

妖精的绣舞 提交于 2019-12-23 09:41:57

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/5356882/how-to-search-secondary-index-in-cassandra-without-equality

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!