Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JAMES-4077 Back memory-app with Lucene #2464

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ enum SearchCapabilities {
Text,
FullText,
Attachment,
AttachmentFileName
AttachmentFileName,
HighlightSearch
}

EnumSet<SearchCapabilities> getSupportedSearchCapabilities();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,8 @@ public org.apache.james.events.Group getDefaultGroup() {

@Override
public EnumSet<SearchCapabilities> getSupportedCapabilities(EnumSet<MailboxManager.MessageCapabilities> messageCapabilities) {
return EnumSet.of(SearchCapabilities.MultimailboxSearch);

return EnumSet.of(SearchCapabilities.MultimailboxSearch,
SearchCapabilities.HighlightSearch);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
import java.util.Locale;
import java.util.Optional;

import jakarta.inject.Inject;
import jakarta.inject.Singleton;

import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MessageId;
Expand Down Expand Up @@ -85,6 +88,8 @@ public LuceneSearchHighlighter(LuceneMessageSearchIndex luceneMessageSearchIndex
this.formatter = new SimpleHTMLFormatter(searchHighlighterConfiguration.preTagFormatter(), searchHighlighterConfiguration.postTagFormatter());
}

@Inject
@Singleton
public LuceneSearchHighlighter(LuceneMessageSearchIndex luceneMessageSearchIndex,
SearchHighlighterConfiguration searchHighlighterConfiguration,
MessageId.Factory messageIdFactory,
Expand All @@ -98,7 +103,7 @@ public LuceneSearchHighlighter(LuceneMessageSearchIndex luceneMessageSearchIndex

@Override
public Flux<SearchSnippet> highlightSearch(List<MessageId> messageIds, MultimailboxesSearchQuery expression, MailboxSession session) {
if (messageIds.isEmpty()) {
if (messageIds.isEmpty() || expression.getSearchQuery().getCriteria().isEmpty()) {
return Flux.empty();
}
return storeMailboxManager.getInMailboxIds(expression, session)
Expand Down
4 changes: 4 additions & 0 deletions server/apps/memory-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@
<groupId>${james.groupId}</groupId>
<artifactId>james-server-guice-lmtp</artifactId>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
<artifactId>james-server-guice-lucene</artifactId>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
<artifactId>james-server-guice-mailbox</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public static void main(String[] args) throws Exception {

LOGGER.info("Loading configuration {}", configuration.toString());
GuiceJamesServer server = createServer(configuration)
.combineWith(new FakeSearchMailboxModule(), new JMXServerModule())
.combineWith(new JMXServerModule())
.overrideWith(new RunArgumentsModule(args));

JamesServerMain.main(server);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
import org.apache.james.events.EventListener;
import org.apache.james.filesystem.api.FileSystem;
import org.apache.james.mailbox.lucene.search.LuceneMessageSearchIndex;
import org.apache.james.mailbox.lucene.search.LuceneSearchHighlighter;
import org.apache.james.mailbox.searchhighligt.SearchHighlighter;
import org.apache.james.mailbox.searchhighligt.SearchHighlighterConfiguration;
import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
import org.apache.james.mailbox.store.search.MessageSearchIndex;
import org.apache.lucene.store.Directory;
Expand All @@ -39,6 +42,9 @@ public class LuceneSearchMailboxModule extends AbstractModule {

@Override
protected void configure() {
bind(SearchHighlighter.class).to(LuceneSearchHighlighter.class)
.in(Scopes.SINGLETON);

bind(LuceneMessageSearchIndex.class).in(Scopes.SINGLETON);
bind(MessageSearchIndex.class).to(LuceneMessageSearchIndex.class);
bind(ListeningMessageSearchIndex.class).to(LuceneMessageSearchIndex.class);
Expand All @@ -53,4 +59,10 @@ protected void configure() {
Directory provideDirectory(FileSystem fileSystem) throws IOException {
return FSDirectory.open(fileSystem.getBasedir().toPath());
}

@Provides
@Singleton
SearchHighlighterConfiguration provideSearchHighlighterConfiguration() {
return SearchHighlighterConfiguration.DEFAULT;
}
}
4 changes: 4 additions & 0 deletions server/container/guice/memory/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
<groupId>${james.groupId}</groupId>
<artifactId>james-server-guice-jmap</artifactId>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
<artifactId>james-server-guice-lucene</artifactId>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
<artifactId>james-server-guice-mailbox</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@
import org.apache.james.mailbox.store.mail.SearchThreadIdGuessingAlgorithm;
import org.apache.james.mailbox.store.mail.ThreadIdGuessingAlgorithm;
import org.apache.james.mailbox.store.mail.UidProvider;
import org.apache.james.mailbox.store.search.MessageSearchIndex;
import org.apache.james.mailbox.store.search.SimpleMessageSearchIndex;
import org.apache.james.mailbox.store.user.SubscriptionMapperFactory;
import org.apache.james.user.api.DeleteUserDataTaskStep;
import org.apache.james.user.api.UsernameChangeTaskStep;
Expand All @@ -90,6 +88,7 @@
import com.google.inject.Scopes;
import com.google.inject.multibindings.Multibinder;
import com.google.inject.name.Names;
import com.google.inject.util.Modules;

public class MemoryMailboxModule extends AbstractModule {

Expand All @@ -99,6 +98,7 @@ protected void configure() {
install(new MemoryDeadLetterModule());
install(new MemoryQuotaModule());
install(new MemoryQuotaSearchModule());
install(Modules.override(new LuceneSearchMailboxModule()).with(new LuceneMemorySearchMailboxModule()));

bind(MessageMapperFactory.class).to(InMemoryMailboxSessionMapperFactory.class);
bind(MailboxMapperFactory.class).to(InMemoryMailboxSessionMapperFactory.class);
Expand Down Expand Up @@ -126,7 +126,6 @@ protected void configure() {
bind(AttachmentManager.class).to(StoreAttachmentManager.class);
bind(SessionProvider.class).to(SessionProviderImpl.class);

bind(MessageSearchIndex.class).to(SimpleMessageSearchIndex.class);
bind(TextExtractor.class).to(JsoupTextExtractor.class);
bind(RightManager.class).to(StoreRightManager.class);
bind(AttachmentContentLoader.class).to(AttachmentManager.class);
Expand Down