Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 12235 invoked from network); 16 Nov 2010 14:17:57 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 16 Nov 2010 14:17:57 -0000 Received: (qmail 8254 invoked by uid 500); 16 Nov 2010 14:18:27 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 8087 invoked by uid 500); 16 Nov 2010 14:18:27 -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 8025 invoked by uid 99); 16 Nov 2010 14:18:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Nov 2010 14:18:27 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of markjreed@gmail.com designates 74.125.82.54 as permitted sender) Received: from [74.125.82.54] (HELO mail-ww0-f54.google.com) (74.125.82.54) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Nov 2010 14:18:19 +0000 Received: by wwi17 with SMTP id 17so99784wwi.23 for ; Tue, 16 Nov 2010 06:17:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=hFoCVgpGUfZ7XGdnuHsXERPKGVWpll4SLgfPH700/iI=; b=Db/JrVTFUmdOq5UMw5WigXgHsrD+fJFZaRzyJz0CAbggpiP94qL/xnWIXgeQE0JVzL 2JUEWIx2VS0+hcoIsz9QVJfnwtcoRZMg8C3bTXfbpiou+htOvxsyBSEDcUOngvhDjpVs NqNnuIoinTrVecYOmeYWyBn2p5qzSg8GGUDmg= 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=E1DPrSzUxhp/52MaLRnSb4bpBGl4dkuvbX5nRNDEKfwQXETHtYRNLWXCyERXVHRcBJ +hQl4J58VLTcLXevZCUUmfCGdfubVJXdRNT4xDYHyXDFOA6RDkRmKTBWqzUlPuv1jDsH FtscJBtRo4ZNB0ZeGAP6wiNaIPVqMvtNsnOC8= MIME-Version: 1.0 Received: by 10.227.128.197 with SMTP id l5mr7793243wbs.22.1289917078555; Tue, 16 Nov 2010 06:17:58 -0800 (PST) Received: by 10.227.27.149 with HTTP; Tue, 16 Nov 2010 06:17:58 -0800 (PST) In-Reply-To: <75870F91-1092-4F46-991C-AA976D2F712F@gmail.com> References: <1366718319.20101116140122@surfulater.com> <75870F91-1092-4F46-991C-AA976D2F712F@gmail.com> Date: Tue, 16 Nov 2010 09:17:58 -0500 Message-ID: Subject: Re: Bulk Updates in CouchDB From: "Mark J. Reed" To: user@couchdb.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On Tue, Nov 16, 2010 at 8:37 AM, Karel Mina=C5=99=C3=ADk wrote: > Hmm, could you explain a bit how it should work? (Because the way I > understand it, you have to iterate over _all_ the docs and check `if > doc.value =3D=3D xxx` in the client code? That'd be impossible for large = data > sets.) Given /mydb/_design/mydd with the following (I'm not bothering with quotation marks, so this isn't copy/pasteable): views: { foo: { map: function(doc) { emit(doc.value, doc._rev) } } } Then you fetch this: /mydb/_design/mydd/_view/foo?key=3D"xxx" Which will include the doc id's and revisions of all the matching docs. Then you use that result to build up a request like this: { docs: [ { _id: someid, _rev: itsrev, _deleted: true }, { _id: someotherid, ...} ] } Which you then post to /mydb/_bulk_docs, and then all the matching docs are deleted, with only two HTTP round-trips. For selective updating, you can use an update handler to modify a document "in-place" without first fetching and then storing the whole thing, but then you can't do that in bulk. --=20 Mark J. Reed