map update in cassandra with cql3

May 21, 2013 in answer

0 votes, 0.00 avg. rating (0% score)

ANSWER:

Better to explain with example, so I am considering only your schema.

Now here i am inserting some data, followed by the output

cqlsh:ks1> update word_cat set
           ...  doc_occurrence=
           ...  'cassandra' : 1
           ...  where word ='name';
cqlsh:ks1> SELECT * FROM word_cat ;

 word | doc_occurrence | total_occurrence
------+----------------+------------------
 name | cassandra: 1 |             null

Now if you want to overwrite an already existing key (cassandra with value 5) in your map, so here you go

cqlsh:ks1> update word_cat set
           ...  doc_occurrence=
           ...  'cassandra' : 5
           ...  where word ='name';

cqlsh:ks1> SELECT * FROM word_cat ;

 word | doc_occurrence | total_occurrence
------+----------------+------------------
 name | cassandra: 5 |             null

Update:

The functionality you are referring in your comment is including a counter value in a map. But unfortunately counters are not allowed inside a collection, rather i will say it is not supported yet.
May be you can have a separate counter column family to handle those things.

abhi from http://stackoverflow.com/questions/16662970