I have a Cassandra table that looks like:
CREATE TABLE messages (
user_id INT,
message_id INT,
received_timestamp TIMESTAMP,
status TEXT,
message TEXT,
PRIMARY KEY ((user_id, message_id),received_timestamp))
WITH CLUSTERING ORDER BY (received_timestamp DESC);
If I try to update a row such as:
UPDATE messages SET status = 'success' WHERE user_id = 1 AND message_id = 1;
I get an error:
Some clustering keys are missing: received_timestamp
I understand that I need to include the received_timestamp because it's part of the primary key, however I'm only including it in the primary key for ordering purposes. Is there no way to perform an update here if I don't know the received_timestamp value? If not, is there a better way to create this table that might work for this use case? Thanks in advance.
received_timestamp
will sort you message according to timestamp ? There will be only onereceived_timestamp
for an user_id and message_id – Ashraful Islam