I'm using Cassandra 2.1.2 with the corresponding DataStax Java driver and the Object mapping provided by DataStax.
following table definition:
CREATE TABLE IF NOT EXISTS ses.tim (id text PRIMARY KEY, start bigint, cid int);
the mapping:
@Table(keyspace = "ses", name = "tim")
class MyObj {
@PartitionKey
private String id;
private Long start;
private int cid;
}
the accessor
@Accessor
interface MyAccessor {
@Query("SELECT * FROM ses.tim WHERE id = :iid")
MyObj get(@Param("iid") String id);
@Query(SELECT * FROM ses.tim WHERE start <= :sstart")
Result<MyObj> get(@Param("sstart") long start);
}
as indicated within the accessor I want to do a query that returns everything where 'start' is smaller or equal than a specific value.
With this definition of the table it's simply not possible. Therefore I tried creating a secondary index:
CREATE INDEX IF NOT EXISTS myindex ON ses.tim (start);
this seems to be not working as well (I read a lot of explanations why its decided to not support this, but I still don't understand why somebody would give such restrictions, anyhow..)
so, as far as I understandd, we have to have at least one equals in the WHERE clause
@Query(SELECT * FROM ses.tim WHERE cid = :ccid AND start <= :sstart")
CREATE INDEX IF NOT EXISTS myindex2 ON ses.tim (cid);
if this would work I would have to know ALL possible values for cid, and query them separately and do the rest on the client... but the error I get is
Cannot execute this query as it might involve data filtering and thus may have unpredictable performance
then I tried
id text, start bigint, cid int, PRIMARY KEY (id, start, cid)
with
@Table(keyspace = "ses", name = "tim")
class MyObj {
@PartitionKey
private String id;
@ClusteringColumn(0)
private Long start;
@ClusteringColumn(1)
private int cid;
}
but still without luck.
furthermore, I tried to set 'start' as PartitionKey, but it's only possible to query with Equals again...
what am I missing? how can I achieve getting results for this type of query?
EDIT: version updated to correct one