Unable to perform range queries in Cassandra 1.2

1k Views Asked by At

I'm accessing Cassandra 1.2 via FluentCassandra and C#. I used the DataStax installation package. The issue I have is I cannot execute the range query I show below.

I have tried the following table create methods:

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))

Here is the query:

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;

The errors are:

"No indexed columns present in by-columns clause with Equal operator" / "PRIMARY KEY part p2 cannot be restricted (preceding part p1 is either not restricted or by a non-EQ relation)"

My 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");

How do I do this?

1

There are 1 best solutions below

1
On BEST ANSWER

As the error specify P2 cannot be restricted UNLESS P1 has EQUAL operator on it ALL parameters until last one you specify must have equality and only the last one can have non-equality