Let's say I currently have a table like this
create table comment_counters
{
contentid uuid,
commentid uuid,
...
liked counter,
PRIMARY_KEY(contentid, commentid)
};
This purpose of this table is to track the comments and the number of times individual comments have been "liked".
What I would like to do is to get the top comments (let's say 20 top comments) determined by their number of likes from this table for each content.
I know there's no way to order by counters so what I would like to know is, are there any other ways to do this in Cassandra, by restructuring my tables or tracking more/different information for instance, or am I left with no choice but to do this in an RDBMS?
Sorting in client is not really an option I would like to consider at this stage.
Unfortunately there's now way to do this type of aggregations using plain Cassandra queries. The best option for doing this kind of data analysis would be to use an external tool such as Spark. Using Spark you can start periodical jobs that would read and aggregate all counters from the comment_counters table and afterwards write the results (such as top 20 comments) to a different table that you can use to query directly afterwards. See here to get started with Cassandra and Spark.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments