couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Davis <paul.joseph.da...@gmail.com>
Subject Re: _rev for random view???
Date Wed, 04 Feb 2009 21:31:32 GMT
On Wed, Feb 4, 2009 at 3:47 PM, Chris Anderson <jchris@apache.org> wrote:
> On Wed, Feb 4, 2009 at 12:41 PM, Paul Davis <paul.joseph.davis@gmail.com> wrote:
>> On Wed, Feb 4, 2009 at 3:18 PM, Chris Anderson <jchris@apache.org> wrote:
>>> On Wed, Feb 4, 2009 at 11:15 AM, Troy Kruthoff <tkruthoff@blit.com> wrote:
>>>>
>>>> Anyone have thoughts on the best way to create a view of random documents?
>>>>  I'm thinking a view with emit(doc._rev,null) would be sufficient for my
>>>> needs, but thought I'd ping the list for collective knowledge ;)
>>>>
>>>
>>> I'm not sure how _rev works for randomness.
>>>
>>> Math.random()
>>>
>>
>> Though you should *NEVER* use Math.random() in a view. Not sure if
>> it's even in the sandbox, but just in case.
>
> I don't think there's anything wrong with using it. If what you want
> is a random order.
>
> More efficient might be to take the seqid of the db, and generate a
> random # smaller than it. Then chose the docid based on the seq.
> however, that will bias for frequently updated docs.
>

http://xkcd.com/221/

Is the desired behavior really to have an output that is the same
'random' on every request? (minus the sameness of docs that were
updated since the last query)

> --
> Chris Anderson
> http://jchris.mfdz.com
>

Mime
View raw message