How can I use the sorting functions over ‘real’ fields in the stored objects? How can I set the field on which I want to sort by?
It seems that the following refers to the key, in my case it’s a UUID, and therefore useless to sort by:
MapReduceResult result = riakClient.
mapReduce("some_bucket").
addMapPhase(new NamedJSFunction("Riak.mapValuesJson"), false).
addReducePhase(new NamedErlangFunction("riak_kv_mapreduce", "reduce_sort"), true).
execute();
thanks.
The other option, if you find sorting via MapReduce too cumbersome, is — sort on the client side.
If your result set is not so huge that you can’t fit it into memory (although if it is, you may have other problems, in terms of MapReduce) — just sort it in java, in memory, when it comes back.