On Tue, Sep 11, 2012 at 10:47 AM, Deepak Balasubramanyam <deepak.b...@gmail.com> wrote: > Hi Mark, > > Sure, I can help whip up a page when I find the time. Do I get access to > edit the wiki or should I email ro...@basho.com ? >
Hmm. Sadly it looks like there's no pull request support for wiki editing on GitHub. (Full explanation here for anyone interested -> http://stackoverflow.com/questions/10642928/how-to-pull-request-a-wiki-page-on-github) At any rate, it looks like the best way is to email Brian directly. I would whip it into a gist in markdown form and send it his way. Thanks. Looking forward to the addition. Mark > Thanks > Deepak Bala > > > On Tue, Sep 11, 2012 at 10:58 PM, Mark Phillips <m...@basho.com> wrote: >> >> Hi Deepak, >> >> In-line >> >> On Tue, Sep 11, 2012 at 10:16 AM, Deepak Balasubramanyam >> <deepak.b...@gmail.com> wrote: >> > I was researching the same question and found the answer after some >> > tinkering around. You need a JS source function. You must write the JS >> > source code for the sort algorithm too. >> > >> > JSSourceFunction phaseFunction = new JSSourceFunction( >> > "function(v) {" + >> > "return v.sort(function(a, b) {" + >> > "return a.field - b.field ;" + >> > "}" + >> > ");" + >> > "}"); >> > IndexQuery iq = new BinValueQuery(BinIndex.named("indx_name"),"bucket", >> > "value"); // get an index >> > MapReduceResult execute = client.mapReduce(iq).addMapPhase(new >> > NamedJSFunction("Riak.mapValuesJson"), >> > false).addReducePhase(phaseFunction).execute(); >> > String resultRaw = execute.getResultRaw(); // Raw data >> > Collection<YourType> result = execute.getResult(YourType .class); // >> > serialized to a domain object >> > >> > The result of this operation will depend on what you return in your >> > reduce() >> > function. The result may be a YourType or YourType[] etc. I wanted to >> > mention that since Jackson can complain about serialization issues if >> > you >> > return the wrong values. >> > >> > Anyone know how to get this into a wiki ? >> >> >> This would probably fit better on the Riak-Java-Client wiki. >> >> https://github.com/basho/riak-java-client/wiki/TODO >> >> There's an open TODO for MapReduce examples and I know Brian would >> love some help with it. Care to take a stab at adding that code? >> >> Mark >> >> > >> > Thanks >> > Deepak Bala >> > >> > On Wed, Aug 29, 2012 at 5:09 PM, Oved Machlev <omach...@interwise.com> >> > wrote: >> >> >> >> Hi, >> >> >> >> >> >> >> >> 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, >> >> >> >> Oved. >> >> >> >> >> >> _______________________________________________ >> >> riak-users mailing list >> >> riak-users@lists.basho.com >> >> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com >> >> >> > >> > >> > _______________________________________________ >> > riak-users mailing list >> > riak-users@lists.basho.com >> > http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com >> > > > _______________________________________________ riak-users mailing list riak-users@lists.basho.com http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com