incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Nolan <peterwno...@gmail.com>
Subject Re: Random Document
Date Tue, 21 Sep 2010 18:14:50 GMT
sounds like a map-reduce is what you're looking for.  Or, you could emit all
the documents, and choose a random row entry on the user end (though that
would be poor practice depending on the size of your database etc.)

On Tue, Sep 21, 2010 at 1:27 PM, Peter Braden <PeterBraden@peterbraden.co.uk
> wrote:

> Hi,
>
> Is there a good way to get a random document from a database. I'm currently
> using a view that does:
>
> function(doc) {
>    emit(Math.random(), doc);
> };
>
> But as this isn't deterministic, I'm pretty sure it's wrong.
>
> I've done a bit of googling, and haven't found anything.
>
> Cheers,
>
> Peter
>
>
>
> --
> Peter Braden
>
> <http://PeterBraden.co.uk/>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message