From 57b1c5d5b5fb42b065fae24fbd92c2b12670a4b0 Mon Sep 17 00:00:00 2001
From: Arun Isaac
Date: Thu, 26 Jan 2023 23:56:51 +0000
Subject: issue: Index names of people as non-boolean terms.

Names of people as non-boolean since it may be required to match them
partially. Think searching for "arun" when the full name is "Arun
Isaac".

* tissue/issue.scm (document-boolean-terms): Remove creator, last
updater and assigned terms.
(document-term-generator): New method.
* tissue/search.scm (%boolean-prefixes): Move creator, lastupdater and
assigned to ...
(%boolean-prefixes): ... here.
---
 tissue/issue.scm  | 15 ++++++++++-----
 tissue/search.scm |  8 ++++----
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/tissue/issue.scm b/tissue/issue.scm
index d5d89bd..c9243ff 100644
--- a/tissue/issue.scm
+++ b/tissue/issue.scm
@@ -62,16 +62,21 @@
 
 (define-method (document-boolean-terms (issue <issue>))
   "Return the boolean terms in ISSUE."
-  (append (list (string-append "A" (file-document-creator issue))
-                (string-append "XA" (file-document-last-updater issue))
-                (string-append "XS" (if (issue-open? issue)
+  (append (list (string-append "XS" (if (issue-open? issue)
                                         "open" "closed")))
-          (map (cut string-append "XI" <>)
-               (issue-assigned issue))
           (map (cut string-append "K" <>)
                (issue-keywords issue))
           (next-method)))
 
+(define-method (document-term-generator (issue <issue>))
+  "Return a term generator indexing ISSUE."
+  (let ((term-generator (next-method)))
+    (index-text! term-generator (file-document-creator issue) #:prefix "A")
+    (index-text! term-generator (file-document-last-updater issue) #:prefix "XA")
+    (for-each (cut index-text! term-generator <> #:prefix "XI")
+              (issue-assigned issue))
+    term-generator))
+
 (define-method (print (issue <issue>) mset port)
   "Print ISSUE, an <issue> object, in search results."
   (let ((number-of-posts (length (file-document-commits issue))))
diff --git a/tissue/search.scm b/tissue/search.scm
index 8dac645..b9feafc 100644
--- a/tissue/search.scm
+++ b/tissue/search.scm
@@ -49,13 +49,13 @@ mapping field names to prefixes."
     query-parser))
 
 (define %prefixes
-  '(("title" . "S")))
+  '(("title" . "S")
+    ("creator" . "A")
+    ("lastupdater" . "XA")
+    ("assigned" . "XI")))
 
 (define %boolean-prefixes
   '(("type" . "XT")
-    ("creator" . "A")
-    ("lastupdater" . "XA")
-    ("assigned" . "XI")
     ("keyword" . "K")
     ("tag" . "K")
     ("is" . "XS")))
-- 
cgit v1.2.3