如何为cassandra columnfamily建模
对于我定义的columnfamily,下面的select查询是可能的,因为我收到了错误的请求错误。我应该如何为我的columnfamily建模以获得正确的结果 创建表记录历史记录 用户id bigint, objectid bigint, 操作文本, 记录链接id bigint, 时间戳, 用户名文本, 价值地图, 主键userid、objectid、操作、记录链接id、时间 通过操作ASC、记录链接id ASC、时间描述的聚类顺序 选择查询:如何为cassandra columnfamily建模,cassandra,cql,cql3,cqlsh,Cassandra,Cql,Cql3,Cqlsh,对于我定义的columnfamily,下面的select查询是可能的,因为我收到了错误的请求错误。我应该如何为我的columnfamily建模以获得正确的结果 创建表记录历史记录 用户id bigint, objectid bigint, 操作文本, 记录链接id bigint, 时间戳, 用户名文本, 价值地图, 主键userid、objectid、操作、记录链接id、时间 通过操作ASC、记录链接id ASC、时间描述的聚类顺序 选择查询: SELECT * FROM recordhisto
SELECT * FROM recordhistory WHERE userid=439035 AND objectid=20011009 AND operation='update' AND time>=1389205800000 AND time<=1402338600000 ALLOW FILTERING;
请求不正确:主键列记录\u链接\u id无法限制前一列操作未受限制或受非EQ关系的限制可能与实际情况重复我在查询中有分区键,并试图通过跳过一些群集列来使用允许筛选。谢谢您的回答,如果我在record_link_id上创建一个索引,我将像select*一样从recordhistory中查询,其中userid=12346,objectid=45646,record_link_id=78946;在这个查询中,cassandra将触及所有节点?是的,我想是这样。Cassandra不会让您执行可能导致系统崩溃的潜在昂贵查询。要执行范围查询,数据必须在磁盘上按连续顺序排列。因此,如果将时间作为第一个聚类列,则可以按时间范围进行查询。
SELECT * FROM recordhistory WHERE userid=439035 AND objectid=20011009 AND record_link_id=20011063 ALLOW FILTERING;
create table recordhistory (
userid bigint,
objectid bigint,
operation text,
record_link_id bigint,
time timestamp,
username text,
value map<bigint, text>,
PRIMARY KEY ((userid, objectid), time, operation, record_link_id)) WITH CLUSTERING ORDER BY (time DESC, operation ASC, record_link_id ASC);
select * from recordhistory where userid=12346 AND objectid=45646 and time >=1389205800000 and time <1402338700000 ALLOW FILTERING;
userid | objectid | time | operation | record_link_id | username | value
--------+----------+--------------------------+-----------+----------------+----------+-------
12346 | 45646 | 2014-06-09 11:30:00-0700 | myop4 | 78946 | name3 | null
12346 | 45646 | 2014-01-08 10:30:00-0800 | myop99999 | 999999 | name3 | null