Hi, Given that map reduce is the primary way of getting data out of riak, and i use python api, I am hard pressed to find any simple examples. Not even on the officially supported riak python api.
Below is how I add a record to riak: id = """%s:%s:%s:%s:%s""" % (str(uuid4()),campaign_id,aid,da,country) worker_bucket = impression_bucket.new(id, data=qs) worker_bucket.add_index('field1_bin', campaign_id) worker_bucket.add_index('field2_bin', aid) worker_bucket.add_index('field3_bin', country) worker_bucket.add_index('field4_bin', da) So.... If I want to get all records and sum up by country and date is in a date range then how? I am ok with the reduce portion but not clear on the map portion. How do I add a index for country=US and da>201207 and da<201212? client = riak.RiakClient(host='103.4.112.103') query = client.add('impressions') query.map(''' function(value, keyData, arg) { var data = Riak.mapValuesJson(value)[0]; var alt_key = data['hw'] + '_' + data['ssp']; var obj = {}; obj[alt_key] = 1; return [ obj ]; }''') Thanks
_______________________________________________ riak-users mailing list riak-users@lists.basho.com http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com