@Kali
All problem has proper solution
For query, we have:
- site as value
We would like to search by date range
CREATE TABLE my_index
(
site text, // row key, also known as partition key
date timestamp, // search by date range
user_id bigint, // user id
session_id uuid, // session id
parameters map<text,text> // pairs of param key/param value
PRIMARY KEY (site,date,user_id,session_id)
)
For each site, we have one row because site = row key
The column name is a composite of (date,*user_id*,*session_id*). Date is the first component so that you get query by date.
*user_id* and *session_id* are there to guarantee UNICITY, meaning that for each timestamp, you can store parameters for more than 1 couple of user_id/session_id
Now, to store parameters, use the MAP feature introduced by CQL3. Parameter names are keys of the map and can be stored as text. For parameter values, since they can be of any type (long, int, string, date ...), it is better to JSON-serialize them as text so you can store them together in the map.
This solution require a little serialize/deserialize before persisting/readign from Cassandra
Example of query:
Get all users,session and parameters for website www.stackoverflow.com between '2013-09-03' and '2013-09-04'
SELECT user_id,session_id,parameters FROM my_index
WHERE site = 'www.stackoverflow.com' AND date>=1378166400
AND date<=1378252800
Get all parameters for website www.stackoverflow.com at date '2013-09-03' and user_id =10
SELECT parameters FROM my_index
WHERE site = 'www.stackoverflow.com'
AND date=1378166400 AND user_id=10