Sort by secondary index

Андрей Хомяков ahomyakov at
Wed May 23 11:02:12 EDT 2012


I'm trying to sort objects in riak by secondary index. Is it possible?

I've read some sources and understood, that standard map-reduce function
for key-sort (reduce_sort in riak_kv_mapreduce.erl)  orders list in memory.
Such approach can be applied to ids, but not the best way for sorting data.

In classic map-reduce model we work with key-value pairs, whitch are
grouped and ordered by key after map step on each map node, so on the
reduce step we have an ordered set of keys with value-sets. In the Riak map
phase returns a plain array of values and the reduce phase works with
concatenated array, produced by all mappers. So we can apply sort only on
reduce phase on large data.

Is there any fast and distributed way to sort data by fields not on reduce
step and not after select?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the riak-users mailing list