This page talks about the primary key of a cassandra table.
The primary key is composed of:
- in first position: the partition keys columns that defines the data location and partition
If you’re searching by an attribute, this attribute should be a part of the primary key
Example of a primary with:
- the partition key columns channel_id, bucket
- the clustering column message_id. The message id is unique.
CREATE TABLE messages ( channel_id bigint, bucket int, message_id bigint, author_id bigint, content text, PRIMARY KEY ((channel_id, bucket), message_id) ) WITH CLUSTERING ORDER BY (message_id DESC);