From user-return-4674-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Fri May 01 17:02:52 2009 Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 56689 invoked from network); 1 May 2009 17:02:51 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 1 May 2009 17:02:51 -0000 Received: (qmail 186 invoked by uid 500); 1 May 2009 17:02:50 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 133 invoked by uid 500); 1 May 2009 17:02:50 -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 Delivered-To: moderator for user@couchdb.apache.org Received: (qmail 45213 invoked by uid 99); 29 Apr 2009 20:42:18 -0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of nborwankar@gmail.com designates 209.85.221.180 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=JjEcoqKQ6bvUQumQOMsd9s5f8bj+ZzbJ5VxWN2wf5H4=; b=kesyU3MjsOuo4x5+XmyqbZmqxH1o8KSbYm6TpU2hNfQc7toPY+rTrpRT8YuDsGf/bO kQ/DJtCZ5bFSh1rmQnqzzpG8JVUPWpJRPD5ABueSNSU+lKgRlzhomsc15fDCAhV9OMG4 NKeE9a5LK3KQvXWP00Fut9IJejte+dyMHs40A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=mfwFFLCH76/u54i/9TXD0Dwd4XKqVc+JU7ZsU64jkM6ylfDxhICTv2HF9G/1yHJ29D L747uyy1nbI98w6p44TqsAvwcTybupaAl1xkOA7G+8zc+IN/MbumCTrk47wZl1LtPTLZ YBmnNI2gVkMOO7xKBmU3dvsR+VniKKbQPpLw8= MIME-Version: 1.0 Sender: nborwankar@gmail.com Date: Wed, 29 Apr 2009 13:41:50 -0700 X-Google-Sender-Auth: 88c42e6a927a01c3 Message-ID: <921000904291341w4ebb8f90yf54c1ae6d3696fcf@mail.gmail.com> Subject: how to access key names of a document? From: Nitin Borwankar To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=00032557620ee32a6c0468b79b0a X-Virus-Checked: Checked by ClamAV on apache.org --00032557620ee32a6c0468b79b0a Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi all, Finding CouchDB very useful and flexible for some of the workflow stuff I am doing to clean up bibliographic data. I have hit a wall in my feeble understanding of map reduce and need some help. I have a database with documents that have varying number of fields. I need to create a view that displays { field_name1 : count, ..... } i.e. a report that displays how many times a field occurs in the db. It's like a word frequency vector in Lucene except for the fact that these are field names. So I am missing something basic but I need to loop over all keys of a doc without knowing their names in advance. so I do something like var x = {} for ( var k in doc.keys ) { x[k] = 1 } emit ( x, 1 ) <---- is this the right thing to emit ? newbie questions a) whats the syntax to access all keys of a doc b) what's the right thing to emit c) what do I do in the reduce phase ? Thanks much, Nitin 37% of all statistics are made up on the spot ------------------------------------------------------------------------------------- Nitin Borwankar nborwankar@gmail.com --00032557620ee32a6c0468b79b0a--