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 597F2D36E for ; Tue, 18 Sep 2012 17:06:14 +0000 (UTC) Received: (qmail 61405 invoked by uid 500); 18 Sep 2012 17:06:12 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 61362 invoked by uid 500); 18 Sep 2012 17:06:12 -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 61338 invoked by uid 99); 18 Sep 2012 17:06:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Sep 2012 17:06:12 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FSL_RCVD_USER,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of simon@cloudant.com designates 209.85.212.52 as permitted sender) Received: from [209.85.212.52] (HELO mail-vb0-f52.google.com) (209.85.212.52) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Sep 2012 17:06:04 +0000 Received: by vbjk17 with SMTP id k17so88609vbj.11 for ; Tue, 18 Sep 2012 10:05:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:x-gm-message-state; bh=TdIJjpduVbljG8WKHfsiVXxaW3h3HVJhokn4JxRX6/Y=; b=kMe71S8wcUnAMlsTzZKHarjGg9Ux+3XXBs5kcx7uJ17NtfmFBYp7QNykRR7OT3IAVd 0lCfDVKeTd7h/LU6a2K9azgP51WF+aSJWPxYr/ES/dFwV74sJ459FQwV5jgK9Lfkoqar RZ9kEQYqP0alXF90MpnyqJpZKRvOD5USb+ExmuQuEUNpWC1zcPbiBsiZbnOEdkUoOYLd tfLOUqXuT4is/DcBJcpICbFjqRfKV+iJ/Q7hHCGg6wmhwAtxTz54WKwAiFNikCKQG7O+ soIX9pFi26fu+MQJgaeTQ4BJqzdMiptd1QZf+LZu6iVLpLxLX3taBpcUQ2pu6cCANNgG z9KA== MIME-Version: 1.0 Received: by 10.58.249.196 with SMTP id yw4mr287003vec.53.1347987943458; Tue, 18 Sep 2012 10:05:43 -0700 (PDT) Received: by 10.220.150.210 with HTTP; Tue, 18 Sep 2012 10:05:43 -0700 (PDT) In-Reply-To: <8FD82E78-16BA-49AC-8D5E-E8C477FEEBFD@me.com> References: <91593B54-D63F-47A6-BB7F-0B176D705C78@me.com> <2D482DCE-31A8-495F-B484-A484F92FA5D0@couchbase.com> <8FD82E78-16BA-49AC-8D5E-E8C477FEEBFD@me.com> Date: Tue, 18 Sep 2012 18:05:43 +0100 Message-ID: Subject: Re: Exclude documents from view based on list of regex expressions From: Simon Metson To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=047d7bacb6248806d004c9fce67c X-Gm-Message-State: ALoCoQlRoYqGvlcIJfY8Ey/+FW8VCaJhG61IQZMl1fL/Pl+0gFP+uYZMml2HPb3KTaqqCvH6uyZr X-Virus-Checked: Checked by ClamAV on apache.org --047d7bacb6248806d004c9fce67c Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Hey Carl, I think you'll want a map like: function(doc) { var reg_exps =3D [/bar/g, /baz/g]; for (r in reg_exps){ if (doc.name.match(reg_exps[r])){ return; } } emit(doc.name, 1); } Cheers Simon On Tue, Sep 18, 2012 at 5:57 PM, Carl Bourne wrote: > Thanks for the advice Jens! > > I'm fairly new to Couch any chance of a simple example that shows how to > build this type of map function? > > Regards, > > Carl > > Carl Bourne | Senior Sales Engineer | mobile: +44 (0) 7770 284294 | > www.venafi.com > > On 18 Sep 2012, at 17:40, Jens Alfke wrote: > > > > > On Sep 18, 2012, at 8:51 AM, Carl Bourne carl.bourne@me.com>> wrote: > > > > Whats the best approach for excluding documents from a view based on a > list of regex expressions. For example I want to exclude anything where > doc.issue.name contains a value that matches a list of regex expressions. > > > > The map function should contain an array of regexes, and match the > doc.issue.name against each one in turn. If it matches any of them, just > return, else emit whatever the appropriate key/value are. > > > > =97Jens > --047d7bacb6248806d004c9fce67c--