Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 58717 invoked from network); 8 Nov 2008 01:05:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Nov 2008 01:05:51 -0000 Received: (qmail 89384 invoked by uid 500); 8 Nov 2008 01:05:56 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 89351 invoked by uid 500); 8 Nov 2008 01:05:56 -0000 Mailing-List: contact couchdb-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-user@incubator.apache.org Delivered-To: mailing list couchdb-user@incubator.apache.org Received: (qmail 89340 invoked by uid 99); 8 Nov 2008 01:05:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Nov 2008 17:05:56 -0800 X-ASF-Spam-Status: No, hits=-2.0 required=10.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of john.bartak@autodesk.com designates 198.102.112.48 as permitted sender) Received: from [198.102.112.48] (HELO paste.autodesk.com) (198.102.112.48) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 08 Nov 2008 01:04:38 +0000 Received: from smtp.mgd.autodesk.com ([65.54.1.156]) by paste.autodesk.com (8.14.1/8.12.6) with ESMTP id mA8154Me021473 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Fri, 7 Nov 2008 17:05:05 -0800 (PST) Received: from ADSK-NAMSG-02.MGDADSK.autodesk.com ([65.54.1.155]) by ADSK-TK5MHUB-01.MGDADSK.autodesk.com ([65.54.1.156]) with mapi; Fri, 7 Nov 2008 17:05:04 -0800 From: John Bartak To: "couchdb-user@incubator.apache.org" Date: Fri, 7 Nov 2008 17:05:03 -0800 Subject: Reduce function error "keys has no properties" Thread-Topic: Reduce function error "keys has no properties" Thread-Index: AclBPggsfzqd0p9fT5KR4Urz5Ds/WA== Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: multipart/alternative; boundary="_000_C686A914549BAB45B21DCEE571C699ED3919632AA1ADSKNAMSG02MG_" MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org --_000_C686A914549BAB45B21DCEE571C699ED3919632AA1ADSKNAMSG02MG_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I get the error "Query Server Log Message: function raised exception (TypeE= rror: keys has no properties)" when I run my reduce function and try to use= the keys parameter. I thought keys was supposed to have the documentId's = for each document passed in through the values parameter? My View looks like: function(doc) { function emitParts(parts,doc) { for (var i =3D 0; i < parts.length; ++i) { emit(parts[i].substr(0,3).toLowerCase(),doc); } } if (doc.type =3D=3D "Person") { var parts; if (doc.Name && typeof(doc.Name) =3D=3D "string") { parts =3D doc.Name.split(new RegExp("[ ]"))= ; emitParts(parts,doc); } if (doc.Email && typeof(doc.Email) =3D=3D "string") { parts =3D doc.Email.split(new RegExp("[.@ ]= ")); emitParts(parts,doc); } } } function( keys, values ) { var usedKeys =3D ''; var reduced =3D []; for ( var i =3D 0; i < keys.length; ++i ) { if (usedKeys.indexOf('%!' + keys[i] + '%!')= =3D=3D -1) { usedKeys =3D usedKeys + '%!= ' + keys[i] + '%!'; reduced.push(values[i]); } } return reduced; } If I remove any reference to keys from the reduce function, the error goes = away. This View creates keys where that are the first 3 characters found in every= word of the Person's eMail and Name fields. The intent of the usedKeys code in the reduce function is deal with the cas= e where a document has an Email field and a Name field that have words that= start with the same 3 characters. It prevents the same document from bein= g inserted in the results twice. --_000_C686A914549BAB45B21DCEE571C699ED3919632AA1ADSKNAMSG02MG_--