You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Hank Knight <hk...@gmail.com> on 2013/10/22 14:28:39 UTC

CouchDB: Return Results in Random Order

This returns 10 results:
http://localhost:5984/mydb/_design/type/_view/q?limit=10&key=%22xyz%22

Is there a way for the results to be returned in random order?

Re: CouchDB: Return Results in Random Order

Posted by Johannes Jörg Schmidt <sc...@netzmerk.com>.
There is rcouch [1], a distribution of couchdb using rebar, is
extensible via custom extensions, one for random docs [3].

[1] https://github.com/refuge/rcouch
[2] https://github.com/refuge/rcouch/wiki/Custom-Extensions
[3] https://github.com/refuge/rcouch/wiki/couch_randomdoc

2013/10/22 Robert Newson <rn...@apache.org>:
>
> Sorry, nope.
>
> On 22 Oct 2013, at 13:28, Hank Knight <hk...@gmail.com> wrote:
>
>> This returns 10 results:
>> http://localhost:5984/mydb/_design/type/_view/q?limit=10&key=%22xyz%22
>>
>> Is there a way for the results to be returned in random order?
>

Re: CouchDB: Return Results in Random Order

Posted by Robert Newson <rn...@apache.org>.
Sorry, nope.

On 22 Oct 2013, at 13:28, Hank Knight <hk...@gmail.com> wrote:

> This returns 10 results:
> http://localhost:5984/mydb/_design/type/_view/q?limit=10&key=%22xyz%22
> 
> Is there a way for the results to be returned in random order?


Re: CouchDB: Return Results in Random Order

Posted by Stanley Iriele <si...@gmail.com>.
What are you trying to randomize?
On Oct 22, 2013 6:23 AM, "Dave Cottlehuber" <dc...@jsonified.com> wrote:

> On 22. Oktober 2013 at 14:29:16, Hank Knight (hknight555@gmail.com) wrote:
> >
> >This returns 10 results:
> >http://localhost:5984/mydb/_design/type/_view/q?limit=10&key=%22xyz%22
> >
> >Is there a way for the results to be returned in random order?
>
> As Bob says, no, but you can fake it. see
> http://blog.chewxy.com/2012/11/16/random-documents-from-couchdb/basically you either do it at view build time, and rebuild periodically, or
> do it at query time
> http://sea-krait.blogspot.co.at/2011/03/cleaner-pseudo-randomized-views-in.htmlby abusing limits and skips.
>
> A+
> Dave Cottlehuber
> Sent with Airmail
>

Re: CouchDB: Return Results in Random Order

Posted by Dave Cottlehuber <dc...@jsonified.com>.
On 22. Oktober 2013 at 14:29:16, Hank Knight (hknight555@gmail.com) wrote:
>
>This returns 10 results:
>http://localhost:5984/mydb/_design/type/_view/q?limit=10&key=%22xyz%22
>
>Is there a way for the results to be returned in random order?

As Bob says, no, but you can fake it. see http://blog.chewxy.com/2012/11/16/random-documents-from-couchdb/ basically you either do it at view build time, and rebuild periodically, or do it at query time http://sea-krait.blogspot.co.at/2011/03/cleaner-pseudo-randomized-views-in.html by abusing limits and skips.

A+ 
Dave Cottlehuber
Sent with Airmail