couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastian Cohnen <sebastiancoh...@googlemail.com>
Subject Re: selecting a random subset of a view
Date Mon, 28 Jun 2010 13:37:03 GMT
depending on your type of keys, I think you can use client-side generated random ids, startkey
and limit to fetch random values from your view.

On 28.06.2010, at 15:29, mickael.bailly@free.fr wrote:

> Hello couchers,
> 
> how would you do to select a random subset of a view result (a simple view with map only).
> 
> Example (I don't write the full view response array for clarity)
> 
> When called normally, my view returns :
> 
> {
> ...
> rows: [
> {id: aa1},
> {id: aa2},
> {id: aa3},
> {id: aa4},
> {id: aa5},
> {id: aa6},
> {id: aa7},
> {id: aa8},
> {id: aa9}
> ]
> }
> 
> And I want only three of those rows, randomly chosen. So I launch the magic "get three
random rows" feature, and it gives me :
> 
> {
> ...
> rows: [
> {id: aa5},
> {id: aa3},
> {id: aa6}
> ]
> }
> 
> The second time I launch the same magic "get three random rows" I got:
> {
> ...
> rows: [
> {id: aa7},
> {id: aa1},
> {id: aa5}
> ]
> }
> 
> Thanks for your advices
> 
> Mickael


Mime
View raw message