From user-return-18978-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Wed Nov 30 20:56:48 2011 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 31A9891D7 for ; Wed, 30 Nov 2011 20:56:48 +0000 (UTC) Received: (qmail 33315 invoked by uid 500); 30 Nov 2011 20:56:46 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 33269 invoked by uid 500); 30 Nov 2011 20:56:46 -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 33260 invoked by uid 99); 30 Nov 2011 20:56:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Nov 2011 20:56:46 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of dave@muse.net.nz designates 209.85.212.52 as permitted sender) Received: from [209.85.212.52] (HELO mail-vw0-f52.google.com) (209.85.212.52) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Nov 2011 20:56:37 +0000 Received: by vbbfk1 with SMTP id fk1so1148310vbb.11 for ; Wed, 30 Nov 2011 12:56:16 -0800 (PST) MIME-Version: 1.0 Received: by 10.52.173.197 with SMTP id bm5mr3652486vdc.7.1322686576598; Wed, 30 Nov 2011 12:56:16 -0800 (PST) Received: by 10.52.30.52 with HTTP; Wed, 30 Nov 2011 12:56:16 -0800 (PST) X-Originating-IP: [84.172.67.25] In-Reply-To: References: Date: Wed, 30 Nov 2011 21:56:16 +0100 Message-ID: Subject: Re: Building views to locate documents WITHOUT a certain set of tags From: Dave Cottlehuber To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On 30 November 2011 21:49, Rob Crowell wrote: > I suppose it would be possible to make multiple queries, using > startkey and endkey to pull out the ranges. > > 1. Sort the "bad" tags: (BROKEN_IMAGE, OFFENSIVE_IMAGE) > 2. For each bad tag, request documents: > =A0 =A0i. Query 1: > =A0 =A0 =A0 =A0startkey =3D [] > =A0 =A0 =A0 =A0endkey =3D ["BROKEN_IMAGE"] > > =A0 =A0ii. Query 2: > =A0 =A0 =A0 =A0startkey =3D ["BROKEN_IMAGE", {}] > =A0 =A0 =A0 =A0endkey =3D ["OFFENSIVE_IMAGE"] > > =A0 =A0iii. Query 3: > =A0 =A0 =A0 =A0startkey =3D ["OFFENSIVE_IMAGE", {}] > =A0 =A0 =A0 =A0endkey =3D [{}] > > Requires making N+1 queries, which for a fairly small list wouldn't be to= o bad. > > On Wed, Nov 30, 2011 at 3:10 PM, Rob Crowell wrot= e: >> Hey everyone, view question here. >> >> I've got couch records that represent images.=A0 They may have any >> number of tags (from zero to hundreds).=A0 However, while there are >> thousands of tags in the dataset, there are only a couple that are >> considered "bad" (BROKEN_IMAGE, BLANK_IMAGE, etc.)=A0=A0Here's an exampl= e >> document: >> >> { >> =A0 =A0_id: ..., >> =A0 =A0url: "http://example.org/whatever.png", >> =A0 =A0tags: ["OUTDOORS", "BEACH", "RED_DRESS"] >> } >> >> I wrote a view to emit documents that don't have these "bad" tags by >> hard-coding the list of bad tags and checking every tag against this >> list. =A0If none of the tags are bad, then emit the document. >> >> However, a user may also specify tags that he doesn't like >> (OFFENSIVE_IMAGE, DENVER_BRONCOS, whatever).=A0 Is there any good way to >> build a view around this idea ("show me all documents that don't have >> a set of tags") short of defining a custom view (with their own "bad" >> tags list) for every user? >> >> I could do this filtering client-side of course, but if I wanted to >> generate an exhaustive list of matching documents (for a report or >> something similar) then it would be a lot of work. =A0I'm stumped at the >> moment. =A0Thanks for any suggestions! >> foo AND bar NOT baz CONTAINS beer Classic use cases for couchdb-lucence or elasticsearch. A+ Dave