I have a data set with attributes content and year. I want to put them in to CF 'words' with attributes ('content','year','frequency'). The CF should support following operations.
- Frequency attribute of a column can be updated (i.e. - : can run query like "UPDATE words SET frequency = 2 WHERE content='abc' AND year=1990;), where clause should contain content and year
- Should support select query like "Select content from words where year = 2010 ORDER BY frequency DESC LIMIT 10;" (where clause only has year) where results can be ordered using frequency
Is this kind of requirement can be fulfilled using Cassandra? What is the CF structure and indexing I need to use here? What queries should I use to create CF and in indexing?
To use ORDER BY, the frequency has to be the second column in a compound PRIMARY KEY (http://www.datastax.com/documentation/cql/3.1/cql/cql_reference/select_r.html?scroll=reference_ds_d35_v2q_xj__using-compound-primary-keys-and-sorting-results). Using the frequency as the key prohibits updates to the value of the key: "Specify the row to update in the WHERE clause by including all columns composing the partition key. The IN relation is supported only for the last column of the partition key. The UPDATE SET operation is not valid on a primary key field." (http://www.datastax.com/documentation/cql/3.1/cql/cql_reference/update_r.html)