[PATCH RFC] index: add body: search query term

Subject: [PATCH RFC] index: add body: search query term

Date: Tue, 9 Oct 2018 22:53:26 -0700

To: notmuch@notmuchmail.org

Cc:

From: William Casarin


This adds the ability to search specifically on the body

eg.

    notmuch search tag:notmuch and body:PATCH

Signed-off-by: William Casarin <jb55@jb55.com>
---

Hey there,

I'm looking to add the ability to search specifically on the body. I
was poking around in the indexer, added these lines and reindexed a
few tags. It appears to work!

I was just wondering if there's anything I'm missing? That seemed a
bit too easy. I noticed there are some NOTMUCH_FIELDS that I'm not
sure what they do.

If anyone has any xapian knowledge that could shine some insight into
what the next steps might be, if any.

Thanks!
Will


 lib/database.cc | 3 +++
 lib/index.cc    | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/database.cc b/lib/database.cc
index 9cf8062c..0b085b21 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -297,6 +297,9 @@ prefix_t prefix_table[] = {
     { "subject",		"XSUBJECT",	NOTMUCH_FIELD_EXTERNAL |
 						NOTMUCH_FIELD_PROBABILISTIC |
 						NOTMUCH_FIELD_PROCESSOR},
+    { "body",			"XBODY",	NOTMUCH_FIELD_EXTERNAL |
+						NOTMUCH_FIELD_PROBABILISTIC |
+						NOTMUCH_FIELD_PROCESSOR},
 };
 
 static void
diff --git a/lib/index.cc b/lib/index.cc
index 3f694387..299b8770 100644
--- a/lib/index.cc
+++ b/lib/index.cc
@@ -506,7 +506,7 @@ _index_mime_part (notmuch_message_t *message,
     body = (char *) g_byte_array_free (byte_array, false);
 
     if (body) {
-	_notmuch_message_gen_terms (message, NULL, body);
+	_notmuch_message_gen_terms (message, "body", body);
 
 	free (body);
     }
-- 
2.19.0

_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch

Thread: