chibenwa commented on code in PR #2926:
URL: https://github.com/apache/james-project/pull/2926#discussion_r2762635957


##########
mailbox/opensearch/src/main/java/org/apache/james/mailbox/opensearch/events/OpenSearchListeningMessageSearchIndex.java:
##########
@@ -370,10 +370,17 @@ public Flux<MessageId> search(MailboxSession session, 
Collection<MailboxId> mail
             return Flux.empty();
         }
 
-        return searcher.searchCollapsedByMessageId(mailboxIds, searchQuery, 
searchOptions, MESSAGE_ID_FIELD, !SEARCH_HIGHLIGHT)
+        return searchCollapsed(mailboxIds, searchQuery, searchOptions)
             .handle(this::extractMessageIdFromHit);
     }
 
+    private Flux<Hit<ObjectNode>> searchCollapsed(Collection<MailboxId> 
mailboxIds, SearchQuery searchQuery, SearchOptions searchOptions) {
+        if (searchQuery.shouldCollapseThreads()) {
+            return searcher.searchCollapsedByThreadId(mailboxIds, searchQuery, 
searchOptions, MESSAGE_ID_FIELD, !SEARCH_HIGHLIGHT);
+        }
+        return searcher.searchCollapsedByMessageId(mailboxIds, searchQuery, 
searchOptions, MESSAGE_ID_FIELD, !SEARCH_HIGHLIGHT);

Review Comment:
   the searcher API should consist of a single method:
   
   `searcher.search(mailboxIds, searchQuery, searchOptions, MESSAGE_ID_FIELD, 
!SEARCH_HIGHLIGHT);` 
   
   As the collapse thing is already part of the search query: no need a double 
representation of the same thing IMO
   
   In the searcher `prepareCollapsedSearch` could call a 
`retrieveCollapseField(searchQuery)` in order to localize this search to the 
maximum.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to