views:

91

answers:

1

I'd like to convert this JSON to a data model in Cassandra, where each of the arrays is a set with no duplicates:

var data = { "data1": { "100": [1, 2, 3], "200": [3, 4] }, "data2": { "k1", [1], "k2", [4, 5] } }

I'd like to query like this: data["data1"]["100"] to retrieve the sets. Anyone know how you might model this in Cassandra? (The only thing I came up with was columns whose name was a set value and the value of the column was an empty string, but that felt wrong.)

It's not OK to serialize the sets as JSON or some other string, which would make this much easier.

Also, I should note that it's OK to split data1 and data2 into separate ColumnFamilies, it's not necessary that they're keys in the same one.

+1  A: 

This sounds like a job for the SuperColumn.

Schildmeijer
That's how I got {name:"3", value:"", timestamp:1234567890},{name:"4", value:"", timestamp:1234567890} to model the set {3,4}, but it didn't feel right. Is there a better way to do it using a SuperColumn?
Ben W