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 17ecaa3c25ef6f849e9ff20731b7e1f430e585a3
Author: Sebb <[email protected]>
AuthorDate: Mon Dec 27 00:39:11 2021 +0000

    Search by message-id must use match
---
 server/plugins/messages.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/server/plugins/messages.py b/server/plugins/messages.py
index da6658a..075cf22 100644
--- a/server/plugins/messages.py
+++ b/server/plugins/messages.py
@@ -225,7 +225,6 @@ async def get_email(
     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.
-    aggtype = "match"
     doc = None
     if permalink:
         try:
@@ -236,6 +235,8 @@ async def get_email(
             if len(permalink) == OLD_SHORTENED_ID_LENGTH and 
re.match(r"^[a-f0-9]+$", permalink):
                 permalink += ".+"
                 aggtype = "regexp"
+            else:
+                aggtype = "match"
             res = await session.database.search(
                 index=doctype,
                 size=1,
@@ -249,7 +250,7 @@ async def get_email(
         res = await session.database.search(
             index=doctype,
             size=1,
-            body={"query": {"bool": {"must": [{aggtype: {"message-id": 
messageid}}]}}},
+            body={"query": {"bool": {"must": [{"match": {"message-id": 
messageid}}]}}},
         )
         if len(res["hits"]["hits"]) == 1:
             doc = res["hits"]["hits"][0]

Reply via email to