【发布时间】:2016-06-13 16:45:31
【问题描述】:
我正在使用 cassandra 2.1.10。 所以首先我要清楚,我知道二级索引在 cassandra 中是反模式的。但出于测试目的,我正在尝试以下操作:
CREATE TABLE test_topology1.tt (
a text PRIMARY KEY,
b timestamp
) WITH bloom_filter_fp_chance = 0.01
AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'}
AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99.0PERCENTILE';
CREATE INDEX idx_tt ON test_topology1.tt (b);
当我运行以下查询时,它给了我错误。
cqlsh:test_topology1> Select * from tt where b>='2016-04-29 18:00:00' ALLOW FILTERING;
InvalidRequest: code=2200 [Invalid query] message="No secondary indexes on the restricted columns support the provided operators: 'b >= <value>'"
虽然Blog 表示允许过滤可用于查询二级索引。 Cassandra 安装在 windows 机器上。
【问题讨论】:
-
thread 中不是您的两个答案解释了在二级索引上不可能进行范围查询。您引用的帖子还解释说,二级索引查询中的 >= 限制仅适用于非索引列并且仅当您允许过滤时才可能。
-
@Ralf 答案之一还说允许过滤将允许范围查询。还有我在问题中提到的 cassandra 的博客和这个帖子 stackoverflow.com/questions/34540883/… 建议相同
标签: cassandra cassandra-2.0 cql3