Re: Random Document

2010-09-23 Thread mickael . bailly
Miller" À: user@couchdb.apache.org Envoyé: Jeudi 23 Septembre 2010 09h10:43 GMT +01:00 Amsterdam / Berlin / Berne / Rome / Stockholm / Vienne Objet: Re: Random Document Use a hash, like sha1 to transform the non-uniform id distribution to a random distribution deterministially. emit(sha1(doc._i

Re: Random Document

2010-09-23 Thread Aaron Miller
ep 21, 2010 at 10:27 AM, Peter Braden < peterbra...@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

Re: Random Document

2010-09-21 Thread Eli Stevens (Gmail)
e > deterministic to do their view updates. > > I'm not entirely convinced that my current function produces a good random > selection - if a document is updated more, and therefore it's view entry is > updated more, does that mean it has a different chance of being selecte

Re: Random Document

2010-09-21 Thread Peter Braden
random selection - if a document is updated more, and therefore it's view entry is updated more, does that mean it has a different chance of being selected? Cheers, Peter On 21 September 2010 20:25, Ian Hobson wrote: > On 21/09/2010 18:27, Peter Braden wrote: > >> Hi,

Re: Random Document

2010-09-21 Thread Ian Hobson
On 21/09/2010 18:27, Peter Braden wrote: Hi, Is there a good way to get a random document from a database. Hmm, that depends upon what you mean by "good", and "random" and if you want a repeatable result! I guess I'm asking what exactly are you trying to do? a) P

Re: Random Document

2010-09-21 Thread Peter Nolan
gt; 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

Random Document

2010-09-21 Thread Peter Braden
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 f