我通过FluentCassandra和C#访问Cassandra 1.2。我使用了DataStax安装包。我遇到的问题是我无法执行下面显示的范围查询。
我试过下面的表创建方法:
CREATE TABLE Test (KEY text, p1 int, p2 int, p3 int, p4 int, p5 int, p6 int,
p7 int, p8 int, data text, PRIMARY KEY (KEY))
CREATE TABLE Test (KEY text, p1 int, p2 int, p3 int, p4 int, p5 int, p6 int,
p7 int, p8 int, data text, PRIMARY KEY (KEY, p1, p2, p3, p4, p5, p6, p7, p8))
以下是查询:
SELECT Data FROM Test WHERE KEY IN (' 0', ' 1',
' 2', ' 3', ' 4', ' 5', ' 6',
' 7', ' 8', ' 9', ' 10', ' 11',
' 12', ' 13', ' 14', ' 15') AND
p1 >= 10 AND p1 <= 40 AND p2 >= 20 AND p2 <= 80 AND
p3 >= 30 AND p3 <= 120 AND p4 >= 40 AND p4 <= 160 AND
p5 >= 50 AND p5 <= 200 AND p6 >= 60 AND p6 <= 240 AND
p7 >= 70 AND p7 <= 280 AND p8 >= 80 AND p8 <= 320;
错误是:
“使用Equal运算符的by-columns子句中没有索引列”/ “PRIMARY KEY部分p2不能被限制(前面部分p1也是 不受限制或非EQ关系)“
我的ConnectionBuilder:
ConnectionBuilder builder = new ConnectionBuilder(CDBkeyspace,
new Server("localhost"), true, 0, 100, 0, ConnectionType.Framed, 4096,
ConsistencyLevel.QUORUM, Apache.Cassandra.ConsistencyLevel.QUORUM, "3.0.0");
我该怎么做?
答案 0 :(得分:4)
由于错误指定P2不能被限制,因此无效P1上有EQUAL运算符 直到您指定的最后一个参数必须具有相等性,并且只有最后一个参数可以具有不相等