Cassandra does not support DELETE on indexed columns

Viewed 7120

Say I have a cassandra table xyz with the following schema :

create table xyz(
xyzid uuid,
name text,
fileid int, 
sid    int,
PRIMARY KEY(xyzid));

I create index on columns fileid , sid:

CREATE INDEX file_index ON xyz (fileid);
CREATE INDEX sid_index ON xyz (sid);

I insert data :

INSERT INTO xyz (xyzid, name , fileid , sid ) VALUES ( now(), 'p120' , 1, 100);
INSERT INTO xyz (xyzid, name , fileid , ssid ) VALUES ( now(), 'p120' , 1, 101);
INSERT INTO xyz (xyzid, name , fileid , sid ) VALUES ( now(), 'p122' , 2, 101);

I want to delete data using the indexed columns :

 DELETE from xyz WHERE fileid=1 and sid=101;

Why do I get this error ?

InvalidRequest: code=2200 [Invalid query] message="Non PRIMARY KEY fileid found in where clause"
  1. Is it mandatory to specify the primary key in the where clause for delete queries ?

  2. Does Cassandra supports deletes using secondary index s ?

  3. What has to be done to delete data using secondary index s ?

  4. Any suggestions that could help .

I am using Data Stax Community Cassandra 2.1.8 but I also want to know whether delete using indexed columns is supported by Data Stax Community Cassandra 3.2.1

Thanks

2 Answers
Related