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 Thu, 27 Nov 2008 12:16:45 GMT
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

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.


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.

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