Pregunta

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.

¿Fue útil?

Solución

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.

Otros consejos

There is a JavaScript reduce function for sorting by field available on the Basho website which you might be able to use. If the structure of the document you want to sort is too complicated for this, you may need to define your own reduce function in JavaScript.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top