You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by se...@apache.org on 2022/01/19 17:22:15 UTC

[incubator-ponymail-foal] 01/02: match does not work against keyword fields

This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git

commit 48dfe5280b721338a463a06f27539913955559ff
Author: Sebb <se...@apache.org>
AuthorDate: Wed Jan 19 17:21:23 2022 +0000

    match does not work against keyword fields
    
    This fixes #210
---
 server/plugins/messages.py | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/server/plugins/messages.py b/server/plugins/messages.py
index d232cf0..cd1e49f 100644
--- a/server/plugins/messages.py
+++ b/server/plugins/messages.py
@@ -219,13 +219,11 @@ async def get_email(
     listid: str = None,
 ) -> typing.Optional[dict]:
     """
-    Returns a matching mbox document or None
+    Returns a single matching mbox document or None
     The calling code is responsible for checking if the entry is accessible
     """
     assert session.database, DATABASE_NOT_CONNECTED
     doctype = session.database.dbs.db_mbox
-    # Older indexes may need a match instead of a strict terms agg in order to find
-    # emails in DBs that may have been incorrectly analyzed.
     doc = None
     if permalink:
         try:
@@ -237,7 +235,7 @@ async def get_email(
                 permalink += ".+"
                 aggtype = "regexp"
             else:
-                aggtype = "match"
+                aggtype = "term"
             res = await session.database.search(
                 index=doctype,
                 size=1,
@@ -248,9 +246,9 @@ async def get_email(
             if len(res["hits"]["hits"]) == 1:
                 doc = res["hits"]["hits"][0]
     elif messageid:
-        bquery = {"query": {"bool": {"must": [{"match": {"message-id": messageid}}]}}}
+        bquery = {"query": {"bool": {"must": [{"term": {"message-id": messageid}}]}}}
         if listid:  # Specific List ID required?
-            bquery = {"query": {"bool": {"must": [{"match": {"message-id": messageid}}, {"term": {"list_raw": listid}}]}}}
+            bquery = {"query": {"bool": {"must": [{"term": {"message-id": messageid}}, {"term": {"list_raw": listid}}]}}}
         res = await session.database.search(
             index=doctype,
             size=1,