2

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?

IamIC
  • 17,747
  • 20
  • 91
  • 154
  • One more thing you should understand about composite columns is "Column Slice must be contiguous" So, p1 > =10 and p1 <= 40 will return you a contiguous slice but filtering the result set with p2 will not work as it is not going to result in a contiguous slice – Tamil Sep 27 '12 at 06:04
  • Per your and @jbellis' previous answer, this should work. "contiguous" sounds like I can only filter on p1. – IamIC Sep 27 '12 at 08:19
  • 1
    Ya p1 alone incase <= or >= conditions and others incase you specify = operator alone. Check my update in previous question – Tamil Sep 27 '12 at 09:47

1 Answers1

4

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