Reputation: 111
I am creating a table in cassandra database but I am getting an allow filtering error:
CREATE TABLE device_check (
id int,
checked_at bigint,
is_power boolean,
is_locked boolean,
PRIMARY KEY ((device_id), checked_at)
);
When I make a query
SELECT * FROM device_check where checked_at > 1234432543
But it is giving an allow filtering error. I tried removing brackets from device_id but it gives the same error. Even when I tried setting only the checked_at as the primary key it still wont work with the > operator. With the = operator it works.
Upvotes: 1
Views: 767
Reputation: 2310
PRIMARY KEY
in Cassandra contains two type of keys
It is expressed as 'PRIMARY KEY((Partition Key), Clustering keys)`
Cassandra is a distributed database where data can be present on any of the node depending on the partition key. So to search data fast Cassandra asks users to send a partition key to identify the node where the data resides and query that node. So if you don't give parition key
in your query then Cassandra complains that you are not querying the right way. Cassandra has to search all the nodes if you dont give it partition key
. Thus Cassandra gives a error ALLOW FILTERING
if you want to query without partition key.
With respect to >
not supported for partition key
, answer remains same as when you give a range search in your query then Cassandra has to scan all the nodes for responding which is not the right way to use Cassandra.
Upvotes: 0