Subject: bug#44509: 28.0.50; Error querying with new gnus-search and notmuch

From: "Jose A. Ortega Ruiz" <[email-masked]>
Date: Sun, 08 Nov 2020 07:09:52 +0000

On Sat, Nov 07 2020, Eric Abrahamsen wrote:

> It's something that's come up on gnus.general several times over the
> years, but I think no one's ever sat down and tried to figure out
> exactly how/if it's supposed to work. Thinking about it logically, I
> just don't see how it could. On my filesystem (in the maildir maintained
> by Dovecot), your message has the filename:
>
> 1604808232.M340024P65055.slip,S=3293,W=3369:2,a
>
> And that's how notmuch will return it. If I search for the same message
> via Dovecot's internal search, the UUID is 1116. Is there anything to go
> from one to the other?

Not to my knowledge.  What you say makes sense and i must be
misremembering... i have a helper function that knows how to find in
gnus a message shown by notmuch, and i use that sometimes to search
using notmuch (counsel-notmuch, actually) while keeping gnus as my main
interface.

> In a few days I can try to set this up and see if there's a way to make
> it work.

That'd be really great.  I'm unfortunately not familiar with
nnir/search, or i'd would have dived a bit into it by now, but i'd be
happy to try and test whatever you come up with.

That said, it's possible to tell notmuch to return message ids instead
of filenames.  For instance, one of the results of the query

     notmuch search --format=sexp messages from:Eric to:jao

looks like:

      ((:thread "000000000002e056" :timestamp 1604811194 :date_relative
      "Today 04:53" :matched 2 :total 5 :authors "Eric Abrahamsen| Jose
      A. Ortega Ruiz, [email-masked]" :subject "bug#44509:
      28.0.50; Error querying with new gnus-search and notmuch" :query
      ("id:[email-masked]
      id:[email-masked]"
      "id:[email-masked]
      id:[email-masked]
      id:[email-masked]") :tags ("inbox" "replied"
      "unread"))

and those values for :query seem to be the ids of this thread.
notmuch-search.el has actually a function notmuch-query-get-message-ids
that directly returns them, and also this one:

  (defun notmuch-query-get-threads (search-terms)
    "Return a list of threads of messages matching SEARCH-TERMS.

where possibly that list contains info from both the path and message
id.

> (BTW have you turned on full text search in your local Dovecot? That
> makes imap searches "fast enough" for me, though I doubt they're as
> fast as notmuch.)

No... i once read that the fastest way was via xapian (if i'm recalling
correctly), but then i saw it's a java thing and lost steam :)

Another reason is that notmuch knows how to index usenet messages just
fine, and i use leafnode to fetch my news to a local server, so i can
play the trick of for instance symlinking leafnode's gwene/gmane message
folders in my ~/var/mail and have a single index for all my mail and
news.  The same function that brings me from notmuch message buffers to
gnus nnimap groups nows how to bring me to nntp groups to.

Cheers,
jao
--
I don't necessarily agree with everything I say.
 -Marshall McLuhan (1911-1980)