Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 258316DE0140 for ; Sat, 16 Jul 2016 17:40:06 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.011 X-Spam-Level: X-Spam-Status: No, score=-0.011 tagged_above=-999 required=5 tests=[AWL=0.000, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KzNxP1zlrPvH for ; Sat, 16 Jul 2016 17:39:57 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id C5EDF6DE0130 for ; Sat, 16 Jul 2016 17:39:57 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.84) (envelope-from ) id 1bOa81-0006MO-MV; Sat, 16 Jul 2016 20:40:17 -0400 Received: (nullmailer pid 25866 invoked by uid 1000); Sun, 17 Jul 2016 00:39:53 -0000 From: David Bremner To: Daniel Kahn Gillmor , Notmuch Mail Subject: Re: [PATCH] add has: query prefix to search for specific properties In-Reply-To: <1467969336-7605-1-git-send-email-dkg@fifthhorseman.net> References: <1465779955-5539-9-git-send-email-david@tethera.net> <1467969336-7605-1-git-send-email-dkg@fifthhorseman.net> User-Agent: Notmuch/0.22+28~gb9bf3f4 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-pc-linux-gnu) Date: Sat, 16 Jul 2016 21:39:53 -0300 Message-ID: <87ziphxfl2.fsf@zancas.localnet> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.20 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, 17 Jul 2016 00:40:06 -0000 Daniel Kahn Gillmor writes: > We want to be able to query the properties directly, like: > > notmuch count has:foo=bar > > which should return a count of messages where the property with key > "foo" has value equal to "bar". > > This patch could be improved: > > If no = sign is present (e.g. "has:foo"), it'd be nice to just match > on every message that has property "foo", regardless of value. At the moment I can't think of a nice easy way to do this. It could do something like that proposed for "tag:*", namely expand it internally into an or query, by traversing the db->allterms_begin("XPROPERTY"). > It would also be good to include some tests. and update notmuch-search-terms(7) ? > * TIMESTAMP: The time_t value corresponding to the message's > @@ -260,6 +263,7 @@ static prefix_t BOOLEAN_PREFIX_EXTERNAL[] = { > { "is", "K" }, > { "id", "Q" }, > { "path", "P" }, > + { "has", "XPROPERTY" }, > /* > * Without the ":", since this is a multi-letter prefix, Xapian > * will add a colon itself if the first letter of the path is Do we want to have the same prefix listed in BOOLEAN_PREFIX_INTERNAL and BOOLEAN_PREFIX_EXTERNAL? this seems quite fragile. If we don't though, we have to use the same prefix name for queries as in the code (which is already sprinkled with _find_prefix ("property") ).