couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mickael.bai...@free.fr
Subject selecting a random subset of a view
Date Mon, 28 Jun 2010 13:29:17 GMT
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