[WIP 0/2] Thread based searching

Mark Walters markwalters1009 at gmail.com
Tue Mar 20 13:11:58 PDT 2012


This is very definitely only a work in progress but there have been
several requests for this or something similar on irc.

It implements a very crude form of thread based search: the user can
ask for all the threads that have a message matching the primary query
and have a (possibly different) message matching a secondary query.

For example notmuch search --secondary-search from:A :AND: from:B
returns all threads that have a message from A and a message from B.

Similarly it allows the user to say "and not" on a thread based way.

For example notmuch search --secondary-search from:A :AND_NOT:
tag:mute returns all threads that have a message from A and no message
with tag:mute.

Anything allowing queries of this form is going to have to do some
parsing of the query (rather than leaving this to xapian). To keep
things as simple as possible this version only tries parsing of this
form if passed --secondary-search and it assumes the last command line
argument is the entire secondary search (so any complex secondary
search should be independently quoted) and that the penultimate
command line argument is either :AND: or :AND_NOT: for thread based
"and" or thread based "and not" respectively.

Finally, the two queries do play a different role even in the :AND:
case. The threads returned are exactly those that match the primary
query in (the order that would normally give) just filtered by
containing a message matching the secondary query. Thus a search for
query_a :AND query_b and a search for query_b :AND: query_a return
threads in different orders, and one may be much faster than the
other.

At the moment this is purely lib and cli (ie no emacs interface).

It is also not heavily tested and interactions with excludes or
anything unusual could easily give strange results.

Anyway I am just posting this in case anyone is interested.

Best wishes

Mark

Mark Walters (2):
  lib: multithread
  cli: search: multithread

 lib/notmuch.h    |   12 ++++++++++++
 lib/query.cc     |   46 +++++++++++++++++++++++++++++++++++++++++++++-
 notmuch-search.c |   19 +++++++++++++++++++
 3 files changed, 76 insertions(+), 1 deletions(-)

-- 
1.7.9.1



More information about the notmuch mailing list