I have a table in Cassandra
with id as Primary Key and name, address, department as clustering key
. Now I have following use cases:
- Get users by id and name
- Get users by id, name and address
- Get users by id, name , address and department
As lower order clustering columns are optional in Cassandra query we are using a Custom accessor In Java
for above use cases.
But we have to write 3 different queries in custom accessor.
For example:
select * from user where id=1 and name='A';
select * from user where id=1 and name='A' and address='a1';
select * from user where id=1 and name='A' and address='a1' and department='d1';
Does Java Driver for Cassandra provides any way so that I can handle all the above mentioned use cases by a single query?
Right now if I am writing a query with all clustering columns and For example if I am trying to get users by id and name only I am getting incorrect result as I cannot pass null and if I pass empty string then Cassandra filters the remaining clustering columns by empty string which is causing the incorrect results.