Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A06EC4BE7 for ; Tue, 31 May 2011 21:04:07 +0000 (UTC) Received: (qmail 85183 invoked by uid 500); 31 May 2011 21:04:06 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 85135 invoked by uid 500); 31 May 2011 21:04:05 -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 85127 invoked by uid 99); 31 May 2011 21:04:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 31 May 2011 21:04:05 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [152.2.2.195] (HELO mxip3i.isis.unc.edu) (152.2.2.195) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 31 May 2011 21:03:58 +0000 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ak4GAIRW5U2sGgRa/2dsb2JhbABThEmTRY8KpyuOJIdWiHSBK4NsgQcEkE+EMA6KeA X-IronPort-AV: E=Sophos;i="4.65,299,1304308800"; d="scan'208";a="89769026" Received: from mr2a.isis.unc.edu (HELO smtp.unc.edu) ([172.26.4.90]) by mxip3o.isis.unc.edu with ESMTP; 31 May 2011 17:03:37 -0400 X-UNC-Auth-As: priem X-UNC-Auth-IP: 76.182.97.234 Received: from [192.168.1.3] (cpe-076-182-097-234.nc.res.rr.com [76.182.97.234]) (authenticated bits=0) by smtp.unc.edu (8.14.4/8.14.3) with ESMTP id p4VL3bxb021950 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Tue, 31 May 2011 17:03:37 -0400 (EDT) Message-ID: <4DE557B0.3010608@email.unc.edu> Date: Tue, 31 May 2011 17:03:44 -0400 From: Jason Priem User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 MIME-Version: 1.0 To: user@couchdb.apache.org Subject: Find CouchDB docs missing an arbitrary field Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi all, I need a CouchDB view where I can get back all the documents that don't have an arbitrary field. This is easy to do if you know in advance what fields a document *might* not have. For example[1], this lets you send view/my_view/?key="foo" to easily retrieve docs without the "foo" field: function (doc) { var fields = [ "foo", "bar", "etc" ]; for (var idx in fields) { if (!doc.hasOwnProperty(fields[idx])) { emit(fields[idx], 1); } } } However, you're limited to asking about the three fields set in the view; something like view/my_view/?key="baz" won't get you anything, even if you have many docs missing field baz. I need a view where it will--where I don't need to specify possible missing fields in advance. Any thoughts? [1] http://wiki.apache.org/couchdb/View_Snippets#Retrieving_documents_without_a_certain_field (apologies for crosspost at http://stackoverflow.com/questions/6183352/find-couchdb-docs-missing-an-arbitrary-field) -- Jason Priem UNC Royster Fellow School of Information and Library Science University of North Carolina at Chapel Hill