From user-return-13727-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Tue Nov 16 13:38:02 2010 Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 90456 invoked from network); 16 Nov 2010 13:38:02 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 16 Nov 2010 13:38:02 -0000 Received: (qmail 57370 invoked by uid 500); 16 Nov 2010 13:38:32 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 57142 invoked by uid 500); 16 Nov 2010 13:38:32 -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 57130 invoked by uid 99); 16 Nov 2010 13:38:31 -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 13:38:31 +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 karel.minarik@gmail.com designates 209.85.215.180 as permitted sender) Received: from [209.85.215.180] (HELO mail-ey0-f180.google.com) (209.85.215.180) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Nov 2010 13:38:22 +0000 Received: by eyf18 with SMTP id 18so216796eyf.11 for ; Tue, 16 Nov 2010 05:38:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer; bh=KHFCF+V8zxzxN8mxrGfrPgeVkLxd/KMqRJajAXCUQ4s=; b=g1rDgvFtb6pWUzxawcYlJZ+YiKbBaijeXfIQ5eexHu4x9t28luMkqWhzA7jy+oSxpU Gxh2IbAi5fKcjHWBEsgVeDyLw7QzuGkFbvtQ/O3IIlw4mUVXpqBZSQ16JnLuNDBhpVYa 1eHxei/oShokqIfs8/empb9hZO6CcTU/uFMmw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=jfIUFNDWrO9CjsAa2eVGcH6Zy4r8ePflqiRvOAReIcc/3oWYaywsMwtBtn9a6wUz/+ VRQmMEM9/yHbL8YcMZxI5wwc/abn2UqvRUuEUntrRL+k8P87xavdvwbYbli9Oup+hJpM wEgzS8lSb6it5G3UgE/CezDsbDItKPIytOLSc= Received: by 10.213.7.16 with SMTP id b16mr4126827ebb.35.1289914681945; Tue, 16 Nov 2010 05:38:01 -0800 (PST) Received: from [192.168.2.104] (151.203.broadband7.iol.cz [88.102.203.151]) by mx.google.com with ESMTPS id v51sm1127776eeh.16.2010.11.16.05.37.59 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 16 Nov 2010 05:38:00 -0800 (PST) Message-Id: <75870F91-1092-4F46-991C-AA976D2F712F@gmail.com> From: =?UTF-8?Q?Karel_Mina=C5=99=C3=ADk?= To: user@couchdb.apache.org In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Subject: Re: Bulk Updates in CouchDB Date: Tue, 16 Nov 2010 14:37:58 +0100 References: <1366718319.20101116140122@surfulater.com> X-Mailer: Apple Mail (2.936) X-Virus-Checked: Checked by ClamAV on apache.org >> My question is how do I do some simple things like: >> 1) Delete all documents where key.value = xxx > > For #1, my current trick is to generate a view with a map function > that looks like this: > > map: function(doc) { > emit(null, doc._rev); > } > > This makes it easy to convert the results of the view (without > stale=ok) into a bulk-delete by iterating over the view, but not > fetching each document to get at the revision. 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 == xxx` in the client code? That'd be impossible for large data sets.) As for the question 1), I'd either do a view to emit `[doc.value, 1]` or index it with fulltext, then get the results back (either querying with `key="xxx"` or `?q=key:xxx`) in batches of ~10.000, get the IDs and revisions and then issue a bulk delete. > 2) Update all documents where key.value = xxx so value = yyy There is no way to do 2), AFAIK. This is not entirely bad, neccessarily. Karel