fix?
This commit is contained in:
@@ -1401,23 +1401,21 @@ public class SolrService {
|
||||
|
||||
for (String coreName : coreNames) {
|
||||
try {
|
||||
logger.info("Recreating Solr core: {}", coreName);
|
||||
logger.info("Clearing Lucene index for core: {}", coreName);
|
||||
|
||||
// Unload the core and delete all index data
|
||||
// Unload the core and delete only the Lucene index files.
|
||||
// deleteIndex=true removes data/index/ only; conf/ and core.properties are preserved.
|
||||
// deleteDataDir=false keeps the data directory so the core can be reloaded in place.
|
||||
org.apache.solr.client.solrj.request.CoreAdminRequest.unloadCore(
|
||||
coreName, true, true, solrClient);
|
||||
logger.info("Unloaded core: {}", coreName);
|
||||
coreName, true, false, solrClient);
|
||||
logger.info("Unloaded core (index deleted): {}", coreName);
|
||||
|
||||
// Recreate the core from its configset (same name as the core)
|
||||
org.apache.solr.client.solrj.request.CoreAdminRequest.Create createReq =
|
||||
new org.apache.solr.client.solrj.request.CoreAdminRequest.Create();
|
||||
createReq.setCoreName(coreName);
|
||||
createReq.setConfigSet(coreName);
|
||||
createReq.process(solrClient);
|
||||
logger.info("Recreated core: {}", coreName);
|
||||
// Reload the core from its existing conf/ directory with a fresh empty index.
|
||||
org.apache.solr.client.solrj.request.CoreAdminRequest.reloadCore(coreName, solrClient);
|
||||
logger.info("Reloaded core with fresh index: {}", coreName);
|
||||
|
||||
} catch (SolrServerException e) {
|
||||
logger.warn("Could not recreate core {} (may not exist yet): {}", coreName, e.getMessage());
|
||||
logger.warn("Could not clear/reload core {} (may not exist yet): {}", coreName, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user