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 8663AD4E3 for ; Tue, 18 Sep 2012 19:46:57 +0000 (UTC) Received: (qmail 37902 invoked by uid 500); 18 Sep 2012 19:46:56 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 37777 invoked by uid 500); 18 Sep 2012 19:46:55 -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 37768 invoked by uid 99); 18 Sep 2012 19:46:55 -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 19:46:55 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FSL_RCVD_USER,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of carl.bourne@me.com designates 17.158.236.238 as permitted sender) Received: from [17.158.236.238] (HELO nk11p04mm-asmtp003.mac.com) (17.158.236.238) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Sep 2012 19:46:51 +0000 MIME-version: 1.0 Content-type: text/plain; charset=windows-1252 Received: from [192.168.1.64] (host86-165-160-238.range86-165.btcentralplus.com [86.165.160.238]) by nk11p04mm-asmtp003.mac.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Jan 3 2012)) with ESMTPSA id <0MAK00MZE9L5JD20@nk11p04mm-asmtp003.mac.com> for user@couchdb.apache.org; Tue, 18 Sep 2012 19:46:30 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.7.7855,1.0.431,0.0.0000 definitions=2012-09-18_06:2012-09-18,2012-09-18,1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 ipscore=0 suspectscore=1 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=6.0.2-1203120001 definitions=main-1209180132 Subject: Re: Exclude documents from view based on list of regex expressions From: Carl Bourne In-reply-to: Date: Tue, 18 Sep 2012 20:46:16 +0100 Content-transfer-encoding: quoted-printable Message-id: <6C6DA708-2F30-442F-A87C-3A346B829612@me.com> References: <91593B54-D63F-47A6-BB7F-0B176D705C78@me.com> To: user@couchdb.apache.org X-Mailer: Apple Mail (2.1486) X-Virus-Checked: Checked by ClamAV on apache.org >>However, I'm puzzled as I would expect it to only return the documents = that match the regex NOT the ones that don't. I can't see a NOT operator = in the syntax anywhere! OK sorry - stupid question its an IF/ELSE statement. I'm more familiar = with Ruby so sorry to appear dumb! On 18 Sep 2012, at 19:57, Carl Bourne wrote: > Gentlemen,=20 >=20 > OK so this works exactly how I would like it to: >=20 > function(doc) { > var reg_exps =3D [/ORA/g, /Hew/g, /VM/g]; > for (r in reg_exps){ > if (doc.subject.name.match(reg_exps[r])){ > return; > } > } > emit(doc.subject.organisation_name, 1); > } >=20 > However, I'm puzzled as I would expect it to only return the documents = that match the regex NOT the ones that don't. I can't see a NOT operator = in the syntax anywhere! >=20 > I haven't tried the compound regex yet though! >=20 >=20 > On 18 Sep 2012, at 18:24, Jens Alfke wrote: >=20 >>=20 >> On Sep 18, 2012, at 10:17 AM, Aur=E9lien B=E9nel = > wrote: >>=20 >> Are you sure an array of regexes would be as efficient as a compound = regex? >>=20 >> Good point =97 I don=92t know the innards of SpiderMonkey but I think = it=92s pretty much a guarantee that a compound regex would be much = faster. In general the fewer times you have to jump out of or into an = interpreter (meaning both JS and the regex state-machine) the better. >>=20 >> If I recall the syntax correctly, it would look like /bar|baz/ =85 = right? >>=20 >> =97Jens >>=20 >=20