1

I am wondering if I could have json data type in the column family:

My table will have a unique row key, and column name of "tweets_json" and column value of json content.

How would I create such a table in CQL/cassandra or using python Driver or CQLengine?

tweet_json = json.encode({
                "tweet_id" : tweet_id,
                "body" : tweet_body,
                "user_name" : this_user,
                "timestamp" : timestamp
            })

Basicall

brain storm
  • 30,124
  • 69
  • 225
  • 393

1 Answers1

3

Just have a text column? If you're not looking to filter on the json, then that should be fine. If you are, then you'll need to store it as proper columns, rather than as json.

ashic
  • 6,367
  • 5
  • 33
  • 54
  • 1
    I would like to filter. Does cassandra not support json? – brain storm Jul 30 '14 at 00:20
  • No. In cassandra, you store data with a schema in rows with columns. You can filter on certain columns depending on how you structure your data. As such, an important part is doing some data modelling based on your query patterns to get the best performance / scalability / cluster utilisation. – ashic Jul 30 '14 at 00:48
  • In your case, you could have a table like this: create table tweets( user_name text, tweet_id text, body text, timestamp timestamp, primary key(user_name, timestamp)); But this would again depend on how you wish to query the info. – ashic Jul 30 '14 at 00:49
  • You can use maps, which collection columns. You can index them in cassandra 2.1. Have a look at http://www.datastax.com/dev/blog/cql-in-2-1 . – ashic Jul 30 '14 at 00:57
  • There are further plans in 3.0 to support JSON that maps onto C* strict schema. – BeepBoop Mar 06 '15 at 20:26