How do you store sets in Cassandra?
- by Ben W
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.