If you want to select items depending on a timerange you should use clustering columns. Your create statement should be:
CREATE TABLE test (
provider_id UUID,
name text,
filename text,
timestamp timestamp,
is_deleted boolean,
PRIMARY KEY ((provider_id, filename), timestamp)
)
Now provider_id + filename is your partition key, and timestamp your clustering column.
The composite partition key consists of provider_id
and filename
. The
clustering column, timestamp
, determine the clustering order of the
data. Generally, Cassandra will store columns having the same
provider_id
but a different filename
on different nodes, and columns
having the same provider_id
and filename
on the same node.
This means that you can now query your data like this:
SELECT * FROM test
WHERE provider_id = 1
AND filename = "test.txt"
AND timestamp >= '2016-01-01 00:00:00+0200' AND ts <= '2016-08-13 23:59:00+0200'
And for a possible update:
UPDATE test
SET name = "test-new"
WHERE provider_id = 1
AND filename = "test.txt"
AND timestamp >= '2016-01-01 00:00:00+0200' AND ts <= '2016-08-13 23:59:00+0200'
More info