以下选择查询是否适用于我定义的列族,因为我收到了一个错误的请求错误。我应该如何对我的列族进行建模以获得正确的结果。
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), operation, record_link_id, time)
) WITH CLUSTERING ORDER BY (operation ASC, record_link_id ASC, time DESC)
选择查询:
SELECT * FROM recordhistory WHERE userid=439035 AND objectid=20011009 AND operation='update' AND time>=1389205800000 AND time<=1402338600000 ALLOW FILTERING;
错误的请求:PRIMARY KEY列"时间"不能被限制(前面的列"record_link_id"要么不受限制,要么受到非EQ关系的限制)
SELECT * FROM recordhistory WHERE userid=439035 AND objectid=20011009 AND record_link_id=20011063 ALLOW FILTERING;
错误的请求:PRIMARY KEY列"record_link_id"不能被限制(前一列"operation"要么不受限制,要么受非EQ关系限制)
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