Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 75975 invoked from network); 6 Feb 2011 10:22:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 6 Feb 2011 10:22:18 -0000 Received: (qmail 35611 invoked by uid 500); 6 Feb 2011 10:22:16 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 35275 invoked by uid 500); 6 Feb 2011 10:22:13 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 35267 invoked by uid 99); 6 Feb 2011 10:22:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Feb 2011 10:22:12 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of robert.newson@gmail.com designates 209.85.214.52 as permitted sender) Received: from [209.85.214.52] (HELO mail-bw0-f52.google.com) (209.85.214.52) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 06 Feb 2011 10:22:05 +0000 Received: by bwz4 with SMTP id 4so3928165bwz.11 for ; Sun, 06 Feb 2011 02:21:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=EeHVch2jjGX/nx9kqgZcDeJf0JebW0duAvWIBG0NhIM=; b=o7stk8DdAsgLHc7khLNd7P2EtIlZ9BwjDizR0xDnYds6KdDURyOz0T5xGhFhBEkDJw hMF9RyCkUheGNZbN9zcGkQOnh4928jVR4nBsUVAo8dcyvk9t9CUk/+LyncRta8Dx52ZC x2/Rspu2TYgsHztbUN/En1KRRcCDJm5CGrNtg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=JpqWEV+nuFHYyaWpSfz80ix9H2cdWla/+bVdwJkBo+KI4g6wBqu5oKPT6fuUXIT80t NNXDbkpVhNnz4ddcWpEjNJa+Z9nYfUlV9Ju/HO7jlNEHxqXFiyVeARgkOO9YAlgVmiVK XMLgzSGjfJgGXpeIq1ASZxtEWSEZ6OrUBx0cA= MIME-Version: 1.0 Received: by 10.204.140.70 with SMTP id h6mr12185612bku.117.1296987705111; Sun, 06 Feb 2011 02:21:45 -0800 (PST) Received: by 10.204.113.146 with HTTP; Sun, 6 Feb 2011 02:21:45 -0800 (PST) In-Reply-To: References: Date: Sun, 6 Feb 2011 10:21:45 +0000 Message-ID: Subject: Re: _changes and filters not working in harmony? From: Robert Newson To: user@couchdb.apache.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org I guess I'm missing something here, but since your function will return false for a deleted document, what's the surprise? A deleted document is exactly this; {"_id":"foo","_deleted":true} It has no type and no attachments, it's therefore filtered out. if you add 'if (doc._deleted) { return true; }' you'll see the delete but, as Randall points out, you'll see all deletes. To solve that, we might want to pass either the previous doc *or* simply add the _deleted:true field when we delete, meaning that your filter would work as-is. B. On Sun, Feb 6, 2011 at 12:36 AM, Randall Leeds wr= ote: > I don't think there's anything wrong with what you're doing here, but I > don't know the code too well. > It sounds like what maybe we need is to pass the old document as a third > parameter or something. > > On Sat, Feb 5, 2011 at 15:59, Timothy Wood wrote: > >> >> I=92ve been playing with the _changes support in concert with the filter >> parameter. I=92m seeing some odd results, though. >> >> In all these cases, my filter function looks like: >> >> function(doc, req) { >> =A0if (doc.type =3D=3D "item" && doc["_attachments"]) { >> =A0 =A0return true; >> =A0} >> =A0return false; >> } >> >> >> 1) If I query for changes with a filter like: >> >> >> http://status-board:5984/status-board/_changes?feed=3Dcontinuous&filter= =3Dapp/items >> >> I=92ll see my test documents (that match the filter) come back. Great. B= ut >> then if I go and delete a document using Futon, no =93_deleted=94:true c= hange >> comes back. If I leave off the filter, I do get a _deleted entry in the >> changes feed. >> >> 2) If I edit the document in Futon (by deleting its last attachment) so >> that it no longer matches the filter, I don=92t get a _deleted entry. I = would >> expect to get one since the change feed reported the document to me (it >> matched the filter) and then it was edited to not match the filter. For = an >> observer following a filtered feed, this delete seems pretty crucial (if= you >> wanted to do a filtered replication, for example). >> >> If I start a an unfiltered _changes feed and then do an insert of a >> document followed by adding an attachment, I get two lines in the _chang= es >> feed. But, if I use the filter, I only get one. That is, unlike the dele= te >> case, the filter doesn=92t note the document until the document matches = the >> filter. Probably a happy accident, but the mirror case (edit to not matc= h >> the filter) should be symmetric and issue a delete change. >> >> In my particular use case, I can probably just drop the filter on the >> server side and do it in the client. Is there something wrong in my use = of >> _changes with a filter? I don=92t see any discussion of this in the book= or on >> the mailing list, but maybe I missed it. >> >> Thanks! >> >> -tim >> >> >