This commit is contained in:
Stefan Hardegger
2026-07-20 12:01:24 +02:00
parent 7722c8348c
commit e999fd609c

View File

@@ -720,7 +720,16 @@ public class SolrService {
throw e;
}
logger.info("Successfully cleared all documents from both cores");
// Clear collections core
try {
solrClient.deleteByQuery(properties.getCores().getCollections(), "*:*",
properties.getCommit().getCommitWithin());
logger.info("Cleared all documents from collections core");
} catch (Exception e) {
logger.warn("Failed to clear collections core (may not exist yet): {}", e.getMessage());
}
logger.info("Successfully cleared all documents from Solr cores");
} catch (Exception e) {
logger.error("Failed to clear all documents", e);
@@ -1384,9 +1393,33 @@ public class SolrService {
}
public void recreateCores() throws IOException {
logger.warn("Solr core recreation not supported through API - cores must be managed via Solr admin");
// Note: Core recreation in Solr requires admin API calls that are typically done
// through the Solr admin interface or by restarting with fresh cores
List<String> coreNames = Arrays.asList(
properties.getCores().getStories(),
properties.getCores().getAuthors(),
properties.getCores().getCollections()
);
for (String coreName : coreNames) {
try {
logger.info("Recreating Solr core: {}", coreName);
// Unload the core and delete all index data
org.apache.solr.client.solrj.request.CoreAdminRequest.unloadCore(
coreName, true, true, solrClient);
logger.info("Unloaded core: {}", 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);
} catch (SolrServerException e) {
logger.warn("Could not recreate core {} (may not exist yet): {}", coreName, e.getMessage());
}
}
}
public void recreateIndices() throws IOException {