Cassandra - Hector:按行键搜索但按进一步表达式过滤?

发布于 2024-11-14 12:29:07 字数 746 浏览 4 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

若相惜即相离 2024-11-21 12:29:07

如果您知道需要按发布日期查询数据,那么使用 Apache Cassandra,您应该以这种方式存储它。

这可以通过两种方式完成:
- 调整上面列族定义中的元数据以包含发布日期上的索引:

update column family Records with column_metadata=[{column_name: releasedate, validation_class: LongType, index_name:releasedate_idx, index_type:0}];    
  • 或者创建一个附加列族,该列族使用发布日期作为键并将键存储到记录列族作为列名。这基本上与上面的二级索引定义执行相同的操作,但使管理更新和查询的过程更加手动。

我建议使用第一种方法,让您可以访问 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:

update column family Records with column_metadata=[{column_name: releasedate, validation_class: LongType, index_name:releasedate_idx, index_type:0}];    
  • or create an additional column family that uses the release date as the key and stores the keys to the record column family as column names. This basically does the same thing as the secondary index definition above, but makes the process of managing updates and querying more manual.

I would suggest the first approach, giving you access to IndexedSlicesQuery and all its goodness.

赠意 2024-11-21 12:29:07

抱歉,目前无法使用 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.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文