couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Kerpe" <>
Subject Re: threaded email view
Date Fri, 28 Nov 2008 10:53:04 GMT
This is an old Problem. Most Clients set this References Header. One way
would be (and some E-Mail-Programs do this) to group by subject, this is of
course easy, you have to remove the Re: and Aw: etc and emit that as key.
E-Mail threading problem is not new and there is no 100% relyable way to do
this. Most programs set the References header, also most the In-Reply-To
Header. I have tested this and the results are good. However you can never
be shure. This approach is called strict_threads in the mutt documentation,
while the subject only approach is called pseudo threads.

When using just the In-Reply-To header it will not be so easy because you
only get the direct "parent". Without iterating over the map results again
you don't get these (you can not do this in one iteration with map/reduce I

The Problem gets even more worse as the RFC says the Message-ID SHOULD be
used, this is not mandatory but it is common sense to use this. Some
E-Mail-Servers add an Message-ID if it has not one.
In one case the RFC says no References header should be used: when a message
has more than one single parent.


2008/11/28 Jedediah Smith <>

> This works if emails always list all of their ancestors in the references
> field. If that is indeed the case then I wasn't aware of it and it certainly
> makes my task simpler.
> I am however still interested in the case where nodes of a data structure
> only link to their immediate parent, just or the sake of discussion.
> Thomas Kerpe wrote:
>> 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

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message