【发布时间】:2020-04-13 21:19:35
【问题描述】:
我有一个 cassandra 表,其结构如下:
CREATE TABLE testKeySpace.table1 (
field1 text,
field2 text,
field3 text,
field4 text,
id uuid,
created_on timestamp,
updated_on timestamp,
PRIMARY KEY ((field1, field2, item_id), field3, field4)
) WITH CLUSTERING ORDER BY (field3 ASC, field4 ASC)
随着时间的推移添加了数据。而在最近的需求中,我必须根据 created_on 从这个表中获取数据。
获取查询是这样的:给定 2 个时间戳 t1 和 t2,我必须获取在 t1 和 t2 之间创建的所有行。
现在我正在使用以下查询来获取所有这些数据:
select * from testKeySpace.table1 where created_on >= t1 and created_on <=t2;
这给了我以下错误:
InvalidRequest: Error from server: code=2200 [Invalid query] message="Predicates on non-primary-key columns (created_on) are not yet supported for non secondary index queries
我尝试过的: Another Question on stackoverflow
我使用查询在 created_on 上添加了索引:CREATE INDEX indexKey ON testKeySpace.table1 (created_on);
仍然没有成功。我遇到了同样的错误。 有人能帮我一下吗。我来自sql域,对cassandra没有太多了解。
【问题讨论】:
标签: cassandra