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
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
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
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,
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
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
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