Skip to content

Commit

Permalink
fix #2800 Handle Exceptions in Suggester Instance Initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
marevol committed Jan 25, 2024
1 parent 0c07a74 commit 38108ad
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/main/java/org/codelibs/fess/helper/SuggestHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,22 @@ public void init() {
settingsBuilder.indicesTimeout(fessConfig.getIndexIndicesTimeout());
settingsBuilder.searchTimeout(fessConfig.getIndexSearchTimeout());
suggester = Suggester.builder().settings(settingsBuilder).build(searchEngineClient, fessConfig.getIndexDocumentSuggestIndex());
suggester.settings().array().delete(SuggestSettings.DefaultKeys.SUPPORTED_FIELDS);
split(fessConfig.getSuggestFieldIndexContents(), ",").of(stream -> stream.filter(StringUtil::isNotBlank).forEach(field -> {
try {
suggester.settings().array().add(SuggestSettings.DefaultKeys.SUPPORTED_FIELDS, field);
} catch (final SuggestSettingsException e) {
logger.warn("Failed to add {}", field, e);
}
}));
suggester.createIndexIfNothing();

if (ComponentUtil.hasPopularWordHelper()) {
popularWordHelper = ComponentUtil.getPopularWordHelper();
}
try {
suggester.settings().array().delete(SuggestSettings.DefaultKeys.SUPPORTED_FIELDS);
split(fessConfig.getSuggestFieldIndexContents(), ",").of(stream -> stream.filter(StringUtil::isNotBlank).forEach(field -> {
try {
suggester.settings().array().add(SuggestSettings.DefaultKeys.SUPPORTED_FIELDS, field);
} catch (final SuggestSettingsException e) {
logger.warn("Failed to add {}", field, e);
}
}));
suggester.createIndexIfNothing();
} catch (final Exception e) {
logger.warn("Failed to initialize Suggester.", e);
}
}

public Suggester suggester() {
Expand Down

0 comments on commit 38108ad

Please sign in to comment.