-1

I found one quote here: https://stackoverflow.com/a/13001495/1539017

Perform a 2i query to get list of message keys for the user, feed that list to a Map/Reduce job to delete the objects.

Does it really possible? Any example exists?

Community
  • 1
  • 1
Alexander Popov
  • 355
  • 4
  • 17

1 Answers1

0

I'm assuming that each message has a key and a value. If so, you don't need a Map/Reduce job, just loop through the key collection output from 2i and invoke delete on it.

Ruby example code follows:

client = Riak::Client.new(nodes)
bucket = client.bucket("messages")

message_keys = bucket.get_index("user_id_bin", user_id)
message_keys.each {|key| bucket.delete(key)}

Keep in mind that as with anything Riak, deletes will propagate eventually.

Srdjan Pejic
  • 8,152
  • 2
  • 28
  • 24