即使我们事先不知道键(或键范围),是否可以使用 cassandra 查询一个值(或一个值集)?
我将用 SQL 来表达这个想法:
SELECT key,value
FROM table1
WHERE value > 10
或者我们总是需要知道密钥?
I am going to express the idea in SQL:
SELECT key,value
FROM table1
WHERE value > 10
Or do we always need to know the key?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想你可以使用自 casssandra 0.7 版本以来可用的二级索引。
您还可以查看以下答案:Cassandra 和二级索引,它们内部如何工作?
建议仅对低基数列使用二级索引,这意味着对于没有许多不同值的列(例如“status”或“status”等列) “优先级”通常只有少数不同的值,如“高”、“中”、“低”)。
如果您使用 Hector 作为 cassandra 客户端,您可以在此处找到如何使用它们的信息:
https://github.com/rantav/hector/wiki/User-Guide
I suppose you can use secondary indexes which are available since version 0.7 of casssandra.
You might also checkout the following answer: Cassandra and Secondary-Indexes, how do they work internally?
it is recommended to use secondary indexes only for low-cardinality columns, which means for columns which do not have many different values (e.g. columns like 'status' or 'priority' which have usually only a handful different values like 'high', 'medium', 'low').
In case you are using Hector as your cassandra client you can find information here how to use them:
https://github.com/rantav/hector/wiki/User-Guide
是的,当然,例如,您可以使用 *
如果您使用 Hector API(例如 CqlQuery),您可以从此查询中获取行列表。
请注意,目前对于二级索引,您必须至少有一个相等条件,因此您的查询只需 value > > 10 行不通。请参阅此问题
Yes, of course, for example, you can use *
If you use the Hector API (e.g. CqlQuery), you can get a list of rows back from this query.
Note, currently for secondary indexes, you must have at least one equality conditional, so your query with just value > 10 would not work. See this question