cassandra - 如何从 Cassandra 获取一系列数据

标签 cassandra cqlsh

[cqlsh 5.0.1 | Cassandra 2.1.0 | CQL 规范 3.2.0 |原生协议(protocol)v3]

table:
CREATE TABLE dc.event (
    id timeuuid PRIMARY KEY, 
    name text

) WITH bloom_filter_fp_chance = 0.01;

如何从 Cassandra 获取时间范围内的数据?

例如,当我尝试 'select * from event where id> maxTimeuuid('2014-11-01 00:05+0000') 和 minTimeuuid('2014-11-02 10:00+0000' )',如此处所示 http://www.datastax.com/documentation/cql/3.0/cql/cql_reference/timeuuid_functions_r.html

我收到以下错误:'code=2200 [无效查询] message="分区键仅支持 EQ 和 IN 关系(除非您使用 token() 函数)"'

我可以保留timeuuid作为主键并满足要求吗?

谢谢

最佳答案

Can I keep timeuuid as primary key and meet the requirement?

不完全是,不。来自 http://www.datastax.com/documentation/cql/3.1/cql/cql_reference/select_r.html

WHERE clauses can include a greater-than and less-than comparisons, but for a given partition key, the conditions on the clustering column are restricted to the filters that allow Cassandra to select a contiguous ordering of rows.

您可以尝试在查询中添加“允许过滤”...但我怀疑这是否有效。我不知道有什么好方法(我也不相信有什么好方法)来标记 timeuuid。我大约 99% 确信分区程序的排序会产生意外的不良结果,即使查询本身会执行并且在您深入研究之前显示为正确的。

顺便说一句,您确实应该检查一下大约一年前提出的类似问题:time series data, selecting range with maxTimeuuid/minTimeuuid in cassandra

关于cassandra - 如何从 Cassandra 获取一系列数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26985669/

相关文章:

cassandra - 无法创建嵌套集合数据类型

cassandra - 在 cassandra 中将一张表复制到另一张表

cassandra - 僵尸的时间戳

solr - 在同一物理节点上运行搜索工作负载和 Cassandra 工作负载

neo4j - Neo4j 使用哪个后端数据库来存储数据?

maven - 在 GeoServer 中安装 GeoMesa Cassandra

linux - 脚本手动工作正常但无法在 crontab 上工作

cassandra - 如何在 Cassandra(特别是 CQLSH)中将字符串或文本作为 blob 插入?

python - CQLSH复制错误类型错误: 'int' object is not iterable

go - 从函数返回 gocql 的 session 变量