Cassandra无效查询"不支持冻结地图列device_details上的地图条目等式谓词"

时间:2016-08-01 09:34:52

标签: cassandra

我有下表:

CREATE TABLE dove.backend_events (
log_time_local timeuuid,
username text,
log_type text,
log_time timestamp,
device_category text,
log text,
device_details frozen<map<text, text>>,
PRIMARY KEY (log_time_local, username, device_details)
);

我正在运行此查询:SELECT * FROM dove.backend_events WHERE device_details['category'] = 'mobile' ALLOW FILTERING;

我收到此错误:InvalidRequest: code=2200 [Invalid query] message="Map-entry equality predicates on frozen map column device_details are not supported"

是什么导致它,我该如何解决? <{1}}不是主键的一部分且未冻结时,不会发生此错误。

1 个答案:

答案 0 :(得分:0)

您可以为device_details添加索引,而不是将其设置为主键(并且不冻结它):

CREATE TABLE dove.backend_events (
log_time_local timeuuid,
username text,
log_type text,
log_time timestamp,
device_category text,
log text,
device_details map<text, text>,
PRIMARY KEY (log_time_local, username)
);

CREATE INDEX dove.device_details_index ON dove.backend_events (ENTRIES(device_details));

通过这种方式,您可以有效地运行查询,而无需使用ALLOW FILTERING

SELECT * FROM dove.backend_events WHERE device_details['category'] = 'mobile';