From e3dfc51d3a5fff5ed05b9859560dc1502b3bcc8b Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Sat, 4 Jun 2022 10:32:34 +0200 Subject: xapian: Store hash of message id when indexing files. --- mumi/xapian.scm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/mumi/xapian.scm b/mumi/xapian.scm index 925f67b..8024c6d 100644 --- a/mumi/xapian.scm +++ b/mumi/xapian.scm @@ -1,5 +1,5 @@ ;;; mumi -- Mediocre, uh, mail interface -;;; Copyright © 2020 Ricardo Wurmus +;;; Copyright © 2020, 2022 Ricardo Wurmus ;;; Copyright © 2020 Arun Isaac ;;; ;;; This program is free software: you can redistribute it and/or @@ -83,6 +83,14 @@ messages and index their contents in the Xapian database at DBPATH." (match (assoc-ref (email-headers (last emails)) 'date) ((? string? s) #f) (date date))) + ;; Store the message ids as base64 strings of all + ;; messages. + (msgids + (string-join (map (compose number->string string-hash) + (filter-map (lambda (headers) + (assoc-ref headers 'message-id)) + (map email-headers emails))) + " ")) (text (string-join (map (match-lambda ((($ headers body) ...) @@ -123,6 +131,7 @@ messages and index their contents in the Xapian database at DBPATH." ((bug-done bug) "done") (else "open")) #:prefix "XSTATUS") (index-text! term-generator file #:prefix "F") + (index-text! term-generator msgids #:prefix "XU") ;; Index subject and body without prefixes for general ;; search. @@ -278,7 +287,8 @@ intact." ("owner" . "XO") ("severity" . "XS") ("tag" . "XT") - ("status" . "XSTATUS")))) + ("status" . "XSTATUS") + ("msgid" . "XU")))) (enq (enquire db query))) ;; Collapse on mergedwith value (Enquire-set-collapse-key enq 2 1) -- cgit v1.2.3