mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-04-27 14:27:28 +08:00
feat: 新增贴文reindex
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package com.openisle.search;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class SearchReindexInitializer implements CommandLineRunner {
|
||||
|
||||
private final OpenSearchProperties properties;
|
||||
private final SearchReindexService searchReindexService;
|
||||
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
if (!properties.isEnabled()) {
|
||||
log.info("Search indexing disabled, skipping startup reindex.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!properties.isReindexOnStartup()) {
|
||||
log.debug("Startup reindex disabled by configuration.");
|
||||
return;
|
||||
}
|
||||
|
||||
searchReindexService.reindexAll();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user