至少在 Cassandra 1.2 中是可能的,但默认情况下它是禁用的,
如果您尝试这样做:
SELECT * from playlist where type = 'sometype' and name = 'somename';
您将收到此错误:
Bad Request: Cannot execute this query as it might involve data filtering and thus may have unpredictable performance. If you want to execute this query despite the performance unpredictability, use ALLOW FILTERING
然后你可以启用它运行这个:
SELECT * from playlist where type = 'sometype' and name = 'somename' ALLOW FILTERING;
在您的示例中,Cassandra 将允许您使用从左到右的主键的完整子集进行查询,例如:
SELECT * from playlist where id = 'someid'; (ALLOWED)
SELECT * from playlist where id = 'someid' and type = 'sometype'; (ALLOWED)
SELECT * from playlist where id = 'someid' and type = 'sometype' and name = 'somename'; (ALLOWED)
SELECT * from playlist where id = 'someid' and type = 'sometype' and name = 'somename' and size=somesize; (ALLOWED)
希望能帮助到你