This is an automated email from the ASF dual-hosted git repository.
hqtran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
The following commit(s) were added to refs/heads/master by this push:
new 92b45c0c0e [ENHANCEMENT] Include filename in search snippet
92b45c0c0e is described below
commit 92b45c0c0e3868b79de650ae5a1b9033138783c1
Author: Benoit TELLIER <[email protected]>
AuthorDate: Thu Jun 12 12:15:16 2025 +0200
[ENHANCEMENT] Include filename in search snippet
---
.../james/mailbox/opensearch/search/OpenSearchSearchHighlighter.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git
a/mailbox/opensearch/src/main/java/org/apache/james/mailbox/opensearch/search/OpenSearchSearchHighlighter.java
b/mailbox/opensearch/src/main/java/org/apache/james/mailbox/opensearch/search/OpenSearchSearchHighlighter.java
index 1454c7ab2d..4f4300c4b5 100644
---
a/mailbox/opensearch/src/main/java/org/apache/james/mailbox/opensearch/search/OpenSearchSearchHighlighter.java
+++
b/mailbox/opensearch/src/main/java/org/apache/james/mailbox/opensearch/search/OpenSearchSearchHighlighter.java
@@ -43,11 +43,13 @@ import reactor.core.publisher.Flux;
public class OpenSearchSearchHighlighter implements SearchHighlighter {
public static final String ATTACHMENT_TEXT_CONTENT_FIELD =
JsonMessageConstants.ATTACHMENTS + "." +
JsonMessageConstants.Attachment.TEXT_CONTENT;
+ public static final String ATTACHMENT_FILENAME_FIELD =
JsonMessageConstants.ATTACHMENTS + "." +
JsonMessageConstants.Attachment.FILENAME;
public static final List<String> SNIPPET_FIELDS = List.of(
JsonMessageConstants.MESSAGE_ID,
JsonMessageConstants.SUBJECT,
JsonMessageConstants.TEXT_BODY,
- ATTACHMENT_TEXT_CONTENT_FIELD);
+ ATTACHMENT_TEXT_CONTENT_FIELD,
+ ATTACHMENT_FILENAME_FIELD);
private final OpenSearchSearcher openSearchSearcher;
private final StoreMailboxManager storeMailboxManager;
@@ -90,6 +92,7 @@ public class OpenSearchSearchHighlighter implements
SearchHighlighter {
Optional<String> highlightedTextBody =
Optional.ofNullable(highlightHit.get(JsonMessageConstants.TEXT_BODY))
.or(() ->
Optional.ofNullable(highlightHit.get(JsonMessageConstants.HTML_BODY)))
.or(() ->
Optional.ofNullable(highlightHit.get(ATTACHMENT_TEXT_CONTENT_FIELD)))
+ .or(() ->
Optional.ofNullable(highlightHit.get(ATTACHMENT_FILENAME_FIELD)))
.map(List::getFirst);
return new SearchSnippet(messageId, highlightedSubject,
highlightedTextBody);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]