fix check if suggest.searchlog is false
@@ -187,34 +187,34 @@ public class SuggestCreator {
}
private int create() {
- if (!ComponentUtil.getFessConfig().isSuggestDocuments()) {
- logger.info("Skip create suggest document.");
+ if (!ComponentUtil.getFessConfig().isSuggestDocuments() && !ComponentUtil.getFessConfig().isSuggestSearchLog()) {
+ logger.info("Skipped to create new suggest index.");
return 0;
}
- logger.info("Start create suggest document.");
-
- final AtomicInteger result = new AtomicInteger(1);
- final CountDownLatch latch = new CountDownLatch(1);
-
final SuggestHelper suggestHelper = ComponentUtil.getSuggestHelper();
- logger.info("Create update index.");
+ logger.info("Creating new suggest index.");
suggestHelper.suggester().createNextIndex();
- logger.info("Store all bad words.");
+ logger.info("Storing all bad words.");
suggestHelper.storeAllBadWords(true);
- logger.info("Store all elevate words.");
+ logger.info("Storing all elevate words.");
suggestHelper.storeAllElevateWords(true);
- logger.info("Parse words from indexed documents.");
+ final AtomicInteger exitCode = new AtomicInteger(0);
+
+ if (ComponentUtil.getFessConfig().isSuggestDocuments()) {
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ logger.info("Parsing words from indexed documents.");
suggestHelper.indexFromDocuments(ret -> {
- logger.info("Success index from documents.");
- result.set(0);
+ logger.info("Success indexing from documents.");
latch.countDown();
}, t -> {
logger.error("Failed to update suggest index.", t);
+ exitCode.set(1);
latch.countDown();
});
@@ -224,18 +224,29 @@ public class SuggestCreator {
if (logger.isDebugEnabled()) {
logger.debug("Interrupted.", ignore);
}
+ exitCode.set(1);
+ }
}
- logger.info("Store search logs.");
+ if (ComponentUtil.getFessConfig().isSuggestSearchLog()) {
+ logger.info("Parsing words from search logs.");
+ try {
suggestHelper.storeSearchLog();
+ } catch (final Exception e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Failed to update suggest index.", e);
+ }
+ exitCode.set(1);
+ }
+ }
- logger.info("Switch indices.");
+ logger.info("Replacing new suggest index.");
suggestHelper.suggester().switchIndex();
- logger.info("Remove old indices.");
+ logger.info("Removing old indices.");
suggestHelper.suggester().removeDisableIndices();
- return result.get();
+ return exitCode.get();
}
private int purge(final LocalDateTime time) {
