【问题标题】:cassandra ordering or sortingcassandra 排序或排序
【发布时间】:2016-05-16 14:56:43
【问题描述】:

需要在不提及分区键的情况下获取表中的最新结果。比如需要最新的推文。面临的问题如下,

    create table test2.threads(
    thread text ,
    created_date timestamp,
    forum_name text,
    subject text,
    posted_by text,
    last_reply_timestamp timestamp,
     PRIMARY KEY (thread,last_reply_timestamp)
)
WITH CLUSTERING ORDER BY (last_reply_timestamp DESC);

只有知道分区键,我才能检索数据。

select * from test2.threads where thread='one' order by last_reply_timestamp DESC;

如何在不提及 where 条件的情况下按 desc 排序最新线程?

【问题讨论】:

    标签: cassandra datastax nosql


    【解决方案1】:

    您的数据模型不适合该目的。分区没有排序。您必须遍历分区键,获取一些,然后查看哪些是应用程序级别的最新。

    【讨论】:

      猜你喜欢
      • 2012-01-05
      • 2021-09-15
      • 1970-01-01
      • 1970-01-01
      • 2012-07-22
      • 2014-03-23
      • 2016-12-21
      • 2016-04-10
      • 1970-01-01
      相关资源
      最近更新 更多