我有以下卡桑德拉表如何爲WHERE條件
cqlsh:mydb> describe table events;
CREATE TABLE mydb.events (
id uuid PRIMARY KEY,
country text,
insert_timestamp 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 country_index ON mydb.events (country);
CREATE INDEX insert_timestamp_index ON mydb.events (insert_timestamp);
正如你可以看到Cassandra的timestamp列進行查詢,指數已經在insert_timestamp
列上創建。
我已通過https://stackoverflow.com/a/18698386/3238864
走後,我雖然下面是正確的查詢
cqlsh:mydb> select * from events where insert_timestamp >= '2016-03-01 08:27:22+0000';
InvalidRequest: code=2200 [Invalid query] message="No secondary indexes on the restricted columns support the provided operators: 'insert_timestamp >= <value>'"
cqlsh:mydb> select * from events where insert_timestamp >= '2016-03-01 08:27:22+0000' ALLOW FILTERING;
InvalidRequest: code=2200 [Invalid query] message="No secondary indexes on the restricted columns support the provided operators: 'insert_timestamp >= <value>'"
但是,隨着country
列WHERE條件不工作查詢。
cqlsh:mydb> select * from events where country = 'my';
id | country | insert_timestamp
--------------------------------------+---------+--------------------------
53167d6a-e125-46ff-bacf-f5b267de0258 | my | 2016-03-01 08:27:22+0000
任何想法爲什麼查詢與時間戳條件不起作用?我的查詢語法有什麼問題嗎?
[Cassandra CQL範圍查詢可能被重複,儘管等於運算符和二級索引](http://stackoverflow.com/questions/24894393/cassandra-cql-range-query-rejected-despite-equality-operator-and- secondary index) –