You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2021/09/07 15:44:34 UTC
[incubator-ponymail-foal] branch master updated: Add a
metadata_only argument for just fetching metadata,
and not the email itself (less traffic via ES)
This is an automated email from the ASF dual-hosted git repository.
humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git
The following commit(s) were added to refs/heads/master by this push:
new d100391 Add a metadata_only argument for just fetching metadata, and not the email itself (less traffic via ES)
d100391 is described below
commit d100391333d82105bef076efa673f9ad0aa9763f
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Tue Sep 7 10:44:32 2021 -0500
Add a metadata_only argument for just fetching metadata, and not the email itself (less traffic via ES)
---
server/plugins/messages.py | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/server/plugins/messages.py b/server/plugins/messages.py
index b1340bd..740fd42 100644
--- a/server/plugins/messages.py
+++ b/server/plugins/messages.py
@@ -306,6 +306,7 @@ async def query(
query_limit=10000,
shorten=False,
hide_deleted=True,
+ metadata_only=False
):
"""
Advanced query and grab for stats.py
@@ -313,11 +314,14 @@ async def query(
docs = []
hits = 0
assert session.database, DATABASE_NOT_CONNECTED
+ es_query = {
+ "query": {"bool": query_defuzzed},
+ "sort": [{"epoch": {"order": "desc"}}],
+ }
+ if metadata_only: # Only doc IDs and AAA fields.
+ es_query["_source"] = ["deleted", "private", "mid", "dbid", "list_raw"]
async for hit in session.database.scan(
- query={
- "query": {"bool": query_defuzzed},
- "sort": [{"epoch": {"order": "desc"}}],
- },
+ query=es_query
):
doc = hit["_source"]
# If email was delete/hidden and we're not doing an admin query, ignore it