So, from what I understand in Couchbase, you can sort the keys * using
descending=true
but in my case I want to sort by values. View Twitter data in json format, my question is What did he call the most popular user?
Each tweet has the structure:
{ "text": "", "entities" : { "hashtags" : [ ... ], "user_mentions" : [ ...], "urls" : [ ... ] }
So, using MongoDB, before reusing the Map function and modifying it a bit, you can use it in Couchbase as follows:
function (doc, meta) { if (!doc.entities) { return; } doc.entities.user_mentions.forEach( function(mention) { if (mention.screen_name !== undefined) { emit(mention.screen_name, null); } } ) }
And then I used the _count decrease _count to count all occurrences of screen_name . Now my problem is How to sort by counter values, and not by key?
thanks
source share