二级索引列上的CQL和范围

var*_*run 8 cql cassandra

以下CQL查询导致错误说明

by-columns子句中没有带有equals运算符的索引列

请注意,该列age已经二次索引.

select * from employee where age > 25
Run Code Online (Sandbox Code Playgroud)

但是我有另一个二级索引列type.所以,当我用那个......

select * from employee where type='engineer' and age > 25
Run Code Online (Sandbox Code Playgroud)

我似乎得到了适当的结果.

这是怎么发生的?

jer*_*ans 13

Cassandra的内置二级索引更像是哈希样式索引,而不是B树.

因此,至少需要一次相等比较才能有效地执行查找(任何其他列谓词都会导致相等匹配的后期过滤).

试试以下维基页面,了解有关Cassandra二级索引的问题的起点:http://wiki.apache.org/cassandra/SecondaryIndexes