Cassandra - Hector:按行键搜索但按进一步表达式过滤?
create column family Records with
comparator = UTF8Type and
column_metadata =
[
{column_name: name, validation_class: UTF8Type},
{column_name: label, validation_class: UTF8Type},
{column_name: releasedate, validation_class: LongType},
我想通过 Row-Key 查询记录,然后进一步检查发布日期(时间戳值)。据我了解:http://www. datastax.com/dev/blog/whats-new-cassandra-07-secondary-indexes,这应该很容易实现,因为我首先按行键查询,然后按发布日期缩小范围。
但如何在赫克托做到这一点呢?
使用 SliceQuery
不起作用。我知道有 IndexedSliceQuery 但我没有二级索引集(如上图所示)。这是正确的并且必须使用 IndexedSliceQuery (即使我没有辅助索引)?
谢谢 马库斯
create column family Records with
comparator = UTF8Type and
column_metadata =
[
{column_name: name, validation_class: UTF8Type},
{column_name: label, validation_class: UTF8Type},
{column_name: releasedate, validation_class: LongType},
I want to query the records by Row-Key and then further do a check on the releasedate (a timestamp value). As far as I understand this: http://www.datastax.com/dev/blog/whats-new-cassandra-07-secondary-indexes, this should easyly be possible as I query first by row key and then narrow down by releasedate.
But how to do this in hector?
Using SliceQuery
does not work. I know there is IndexedSliceQuery
but I do not have s secondary index set (as can be seen abolve). Is it neverthelss correct and an must to use IndexedSliceQuery (even though I do not have a seconary Index)??
Thanks
Markus
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您知道需要按发布日期查询数据,那么使用 Apache Cassandra,您应该以这种方式存储它。
这可以通过两种方式完成:
- 调整上面列族定义中的元数据以包含发布日期上的索引:
我建议使用第一种方法,让您可以访问 IndexedSlicesQuery 及其所有优点。
If you know that you need to query your data by release date then, with Apache Cassandra, you should store it that way.
This can be done in two ways:
- adjust the meta data in the column family definition above to include an index on releaseddate:
I would suggest the first approach, giving you access to IndexedSlicesQuery and all its goodness.
抱歉,目前无法使用 Cassandra API 混合服务器端行和列过滤。 (而且由于它只对保留顺序的分区器有意义,因此这不太可能改变。)
Sorry, mixing server-side row and column filtering is not currently possible with the Cassandra API. (And since it only makes sense for order-preserving partitioners, this is unlikely to change.)