hello all, we are having issues sorting in Reduce. this is from within a java app.
we are passing in an anonymous js function, but the values are not being sorted.
here is the data structure:
[{"score":77.88765180825125,"key":"{\"@class\"[cid:[email protected]]"name1\"},
{"score":167.33742092903964,"key":"{\"@class\"[cid:[email protected]]"name2\"
}]
so it is an array of maps, with two keys ('score' & 'key').. the 'score' key is
an integer that we would like to sort on. the 'key' key is a json object that
we have removed from this example.
here is the java code, that executes, but does not sort:
builder = builder.reduce(JavascriptFunction.anon("" +
"function(values){" +
"var flattened = values.reduce(function(a,b){" +
"return a.concat(b);" +
"},[]);" +
"return flattened.sort(function(a,b){ " +
"return b[\"score\"] -a[\"score\"]" +
"});" +
"}"),true);
MapReduceResponse response = builder.submit();
advTHANKSanced,
barron
<<inline: I Don't Know.png>>
_______________________________________________ riak-users mailing list [email protected] http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
