linagora/james-project

[SearchSnippet] Implement Lucene SearchHighlighter

Closed this issue · 2 comments

Why

As we plan to really use Lucene as a search option, we need to back JMAP SearchSnippet extension by implementing a Lucene Search Highlight APIs.

How

  • Add Maven dependency in apache-james-mailbox-lucene:
  <dependency>
      <groupId>org.apache.lucene</groupId>
      <artifactId>lucene-highlighter</artifactId>
      <version>${lucene.version}</version>
  </dependency>
  • Implement LuceneSearchHighlighter in apache-james-mailbox-lucene.
class LuceneSearchHighlighter implements SearchHighlighter {
  Publisher<SearchSnippet> highlightSearch(MultimailboxesSearchQuery expression, MailboxSession session, long limit) {
    ...
  }
}

Using the Lucene highlight APIs: https://lucene.apache.org/core/9_0_0/highlighter/org/apache/lucene/search/highlight/package-summary.html
From what I see, with Lucene, highlight works on search result - which mean we need to search again.

POC: quantranhong1999@a8ddbe5

DoD

Pass contract tests

We can reuse class LuceneMemorySearchHighlighter (In pr Lucene memory impl ) for Lucene FS impl.
The fact LuceneMemorySearchHighlighter only use lucene highlight api, it's nothing special just for memory.

  • Consider extract LuceneMemorySearchHighLightTest to contract class -> and new one Lucene FS impl test