From couchdb-user-return-2014-apmail-incubator-couchdb-user-archive=incubator.apache.org@incubator.apache.org Thu Nov 27 14:09:48 2008 Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 38834 invoked from network); 27 Nov 2008 14:09:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 Nov 2008 14:09:48 -0000 Received: (qmail 32946 invoked by uid 500); 27 Nov 2008 14:09:58 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 32916 invoked by uid 500); 27 Nov 2008 14:09:58 -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 32902 invoked by uid 99); 27 Nov 2008 14:09:58 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Nov 2008 06:09:58 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of thomas.kerpe@googlemail.com designates 209.85.217.15 as permitted sender) Received: from [209.85.217.15] (HELO mail-gx0-f15.google.com) (209.85.217.15) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Nov 2008 14:08:29 +0000 Received: by gxk8 with SMTP id 8so1002532gxk.12 for ; Thu, 27 Nov 2008 06:09:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:user-agent :mime-version:to:subject:references:in-reply-to:content-type :content-transfer-encoding:from; bh=cGQd9CVJO7EYS05kyPDGfAgo/czhpKYii5TtSuB50qQ=; b=ATkln1gtiJmzSd4jsCVOllgypB5fJYQwRBKKLzPMI3Gl9B8uGgdHBZTf2aw1g04Bo7 /nZ9O0/JtHADKwVLi5beHVvFFNXUydL+51XYjtZ0OdFhbmpXy/Q+3ASXYzS0n9/MbDHL w/EpeSk0RBA3zUWHMmPt8ppM8S0+TUHTCcf9I= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding:from; b=EnhM6u6vFsAc01Vc+EUvVNNRHEi3SKriCzWWuyo669ksfD/MZUGhBE9y/9jPyZOeT/ yz2Wq6zyBrJNY4gymthYv3PDTqQNcgu9vo+zCBZr6q6WL0CCKXir9OJDuAWyyvT02JJW Eft4J/Uc36S44vD+TXeL4GffUglhVlDTEGifg= Received: by 10.86.29.8 with SMTP id c8mr4605748fgc.67.1227794804257; Thu, 27 Nov 2008 06:06:44 -0800 (PST) Received: from Calvin.home.kerpe.net (HSI-KBW-078-042-025-132.hsi3.kabel-badenwuerttemberg.de [78.42.25.132]) by mx.google.com with ESMTPS id d6sm2434058fga.2.2008.11.27.06.06.43 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 27 Nov 2008 06:06:43 -0800 (PST) Message-ID: <492EA96F.3080603@gmail.com> Date: Thu, 27 Nov 2008 15:06:39 +0100 User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; de; rv:1.9.1b1pre) Gecko/20081006 Shredder/3.0a3 MIME-Version: 1.0 To: couchdb-user@incubator.apache.org Subject: Re: threaded email view References: <492A505E.5050104@silencegreys.com> <78ea81000811270416h3804f94fyb35a227c57fbc78a@mail.gmail.com> In-Reply-To: <78ea81000811270416h3804f94fyb35a227c57fbc78a@mail.gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit From: Thomas Kerpe X-Virus-Checked: Checked by ClamAV on apache.org Hoops, sorry for that html and broken Text-part: function(doc) { if (doc.type == "email") { thread = []; if (doc.header.references){ thread = doc.header.references.split(" "); } thread.push(doc.header['message-id']); thread_id = thread[0]; emit([thread_id, thread,], doc.header.subject); } } //Thomas Am 27.11.2008 13:16 Uhr, Thomas Kerpe schrieb: > Jedediah, > > This should be really easy. When you have for shure unique Message-IDs > you can let identify your threads and single messages with them. Your > map will emit > > function(doc) { > if (doc.header.references){ > thread = doc.header.references.split(" "); > thread.push(doc.header['message-id']); > thread_id = thread[0]; > } else { > thread = [doc.header['message-id']]; > thread_id = doc.header['message-id']; > } > emit([thread_id, thread, ], null); > } > > In this way you can build your indexes. Maybe add a date or the sender > adddress to your key. In this way you can get whole threads by knowing > only one message ID. > > > HTH, > //Thomas > > 2008/11/24 Jedediah Smith > > > I'm using CouchDB to store and process emails. > > Every email has a "message-id" header field containing a globally > unique identifier and zero or more "references" and "in-reply-to" > fields, each of which contains the message-id of a different message. > > To construct a threaded view, a tree structure is built using > "references" and "in-reply-to" as parent links. This implies that > a message can have more than one parent, in which case it would > appear multiple times in the view. > > I would like to have a CouchDB view that allows me to easily > construct threads in this way. Specifically, given a particular > message, I want to get all of its directly or indirectly connected > messages. Messages don't need to be in any particular order within > a thread. It can be assumed that a thread contains a small number > of messages, say <100 > > The view might have one or more other key fields (e.g. date) which > will be used to sort the threads or restrict the range. When a > range is given, the view returns all messages from each thread > that contains at least one message in the range. > > I want to be able to handle each of these cases with one request, > without storing intermediate data in documents. > >