-1

When I have a table like this in Cassandra:

CREATE TABLE amout( ID int, date timestamp, countValue counter, PRIMARY KEY ((ID), date));

I know about the partitioning key's as stated here:Difference between partition key, composite key and clustering key in Cassandra? But a counter cannot be part of the primary key. Now I want to query based upon the countValue for example like this:

SELECT * from amount WHERE countValue > 10;

Of course this will give an undefined name exception. But is it possible to achieve a query like this without doing something like SELECT * FROM amount; and then go through the dataset? I want to get the dataset I need.

Community
  • 1
  • 1
Proliges
  • 371
  • 4
  • 26
  • If you have DSE (DataStax Enterprise Cassandra) then you might be able to pull it off with in-built Solr indexing. But there is no straight forward way, counter scanning is not supported except by key. – Sreekar Oct 17 '16 at 18:29
  • @Sreekar I think I am going to use SQL for it. Got a pretty large Cassandra database next to a SQL environment so its easy to switch for me. – Proliges Oct 18 '16 at 07:48

1 Answers1

2

This is not something you can do in Cassandra. You will need to use some other process such as the client side filtering like you suggested.

Another option would be instead of doing the counter in the table you can just keep the records separate and do some post processing in something like Spark.

Jeff Beck
  • 3,944
  • 3
  • 28
  • 45
  • Well client side filtering might not be the best way to do this operation, i have to select in an ever growing database. Maybe I will do this in SQL but maybe I can create a tabel where `countValue` is an integer. Then i should be able to loop through it if i'm correct. – Proliges Oct 18 '16 at 07:52