couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Kerpe <thomas.ke...@googlemail.com>
Subject Re: threaded email view
Date Thu, 27 Nov 2008 14:06:39 GMT
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 <jedediah@silencegreys.com 
> <mailto:jedediah@silencegreys.com>>
>
>     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.
>
>


Mime
View raw message