incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Newson <robert.new...@gmail.com>
Subject Re: Suppressing duplicate documents from a view query
Date Fri, 10 Dec 2010 14:28:22 GMT
"I seem to remember that there is a request flag that can be passed to
a view query to eliminate document duplicates."

I've never heard of such an option.

To remove duplicate keys from a view, use a reduce function like
"return null" and query with reduce=true.

B.

On Fri, Dec 10, 2010 at 2:08 PM, Jean-Pierre Fiset <jp@fiset.ca> wrote:
> This question relates to CouchDb 1.0.1.
>
> I have been reading as much as I can about CouchDb and started implementing an application.
I
> seem to remember that there is a request flag that can be passed to a view query to eliminate
> document duplicates. However, I do not recall which one it is. A quick review of the
wiki did
> not shed any light.
>
> Currently, I am removing duplicates by using a list function. I have documented the details
of
> the list function here:
> http://www.bitsbythepound.com/remove-document-duplicates-from-couchdb-view-query-using-a-list-function-366.html
>
> In short, this is the list function:
>
> function(head, req) {
>    send('{"total_rows":'+head.total_rows
>        +',"offset":'+head.offset+',"rows":[');
>    var ids = {}
>        ,row
>        ,first = true
>        ;
>    while(row = getRow()) {
>        if( !ids[row.id] ) {
>            if( first ) {
>                first = false;
>            } else {
>                send( ',' );
>            };
>            send( toJSON(row) );
>            ids[row.id] = 1;
>        };
>    };
>    send(']}');
> }
>
> Questions:
> 1. Is there a much simpler way to achieve this?
> 2. If the list function is the way to solve the problem, can someone comment on the likelihood
> that this function will sustain the scaling up of the database?
>
> Thanks,
>
> JP
>

Mime
View raw message