Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id B2A4D429E25 for ; Sat, 10 Dec 2011 17:03:58 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IGPwMGEZdg-i for ; Sat, 10 Dec 2011 17:03:58 -0800 (PST) Received: from mail-iy0-f181.google.com (mail-iy0-f181.google.com [209.85.210.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 33C68431FB6 for ; Sat, 10 Dec 2011 17:03:58 -0800 (PST) Received: by iaoo28 with SMTP id o28so6449952iao.26 for ; Sat, 10 Dec 2011 17:03:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=tLY/qNwBXmmsh05b9U4kAIMS4kez5+BJA70qGDyQd5k=; b=T2xH05wnc09z8tjNSSTbl7UZHX+68nuCL2YEpMNfZMiAtjQHP5K9O5wjzeDMUGOkJK 51i6ml09dLLqorna+R80HUV8hXg5Qbxl1KE9XDXoLiryPiAA4yVvpA/Eky3Qb7LV/7CX qajUrNLnSUJQDE/3o4X+/DU5Inot5Ig3kkOd4= MIME-Version: 1.0 Received: by 10.182.54.80 with SMTP id h16mr1715660obp.59.1323565437768; Sat, 10 Dec 2011 17:03:57 -0800 (PST) Received: by 10.182.222.35 with HTTP; Sat, 10 Dec 2011 17:03:57 -0800 (PST) In-Reply-To: <878vmk581q.fsf@servo.finestructure.net> References: <87zkf05gk4.fsf@servo.finestructure.net> <878vmk581q.fsf@servo.finestructure.net> Date: Sun, 11 Dec 2011 03:03:57 +0200 Message-ID: Subject: Re: Exporting a single email as JSON From: Ciprian Dorin Craciun To: Jameson Graef Rollins Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: notmuch@notmuchmail.org X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Dec 2011 01:03:58 -0000 On Sun, Dec 11, 2011 at 01:19, Jameson Graef Rollins wrote: > On Sun, 11 Dec 2011 00:46:51 +0200, Ciprian Dorin Craciun wrote: >> =C2=A0 =C2=A0 * in my use-case I would need each line of the output to b= e a >> standalone JSON object of an individual message; (thus I can script >> with Bash `notmuch ... | while read message ; do ... ; done`;) > > This is actually a slightly different idea than what I thought you were > originally proposing. =C2=A0Outputting a series of json objects rather th= an a > single list has been talked about for notmuch search as well. =C2=A0I'm d= on't > have a good sense of whether this is a sensible idea or not. > >> =C2=A0 =C2=A0 * maybe someone else would need that the output to contain >> **exactly one** such message (maybe the first); > > This is what I thought we were talking about. =C2=A0This is an option I w= ould > like to see, at least. Indeed exporting multiple messages as top / root JSON objects isn't quite usable except limited import / export use-cases, thus what you propose is more sensible. And in the end by having this possibility I could easily implement the solution I'm seeking as simple as: ~~~~ notmuch --output=3Dmessages -- {criteria} \ | xargs -L 1 -- notmuch show --format=3Djson -- \ | while read message_json ; do ... ; done ~~~~ But there is only one problem with such an approach: efficiency. With the snippet above I'll have as many `notmuch` process executions as messages. (And I do have quite a few of them.) Thus although Notmuch is quite fast -- as in human imperceptible -- still opening and closing the Xapian database so many times does have quite an overhead. So in the end I think a discussion about the needed (/ wanted) use-cases would be better. Ciprian. P.S.: I could help implement (or at least prototype) some of these use-cases. Thus I'll watch over the thread you've pointed me to.