Cassandra Sort Results by Account

I record data about users who search for various keywords. What I would like to create is a report on all the unique keywords that users searched, sorted in ascending and descending order, by the number of search queries.

Is it something that can be modeled with Cassandra, and if so, what would the model look like?

Thanks!

+4
source share
2 answers

According to the eBay tech blog , it is unusual to store your counter values ​​in the key itself. Therefore, in order to save the number of times, Bob, Ken and Jimmy entered the website, one line would look like this:

logins: [(0001_Bob,''), (0002_Bob, ''), ..., (0010_Ken, ''), (0012_Jimmy, ''), ...]

Please note that your keys will automatically sort themselves with the highest counter at the end, and this is close to constantly looking at the time.

Please note that each time your user logs in, a new column is created. You will need to track the amount of input in another line so that you have a quick search for the amount of input so far and what integer value your next key has:

login_count: [(Bob, 2), (Ken, 10), (Jimmy, 10), ...]

+2
source

You can use each keyword as a row key and use a column column for each row to track the number of queries. Then you can create a report by looking at each line and reading the counters. Cassandra will not sort the results (assuming you are using the DefaultPartitioner by default, not the OrderPreservingPartitioner), but assuming there are supposed to be only a few tens of thousands of keywords, you can easily sort them on the client.

0
source

Source: https://habr.com/ru/post/1391006/


All Articles