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