solr fix
This commit is contained in:
@@ -720,7 +720,16 @@ public class SolrService {
|
|||||||
throw e;
|
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) {
|
} catch (Exception e) {
|
||||||
logger.error("Failed to clear all documents", e);
|
logger.error("Failed to clear all documents", e);
|
||||||
@@ -1384,9 +1393,33 @@ public class SolrService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void recreateCores() throws IOException {
|
public void recreateCores() throws IOException {
|
||||||
logger.warn("Solr core recreation not supported through API - cores must be managed via Solr admin");
|
List<String> coreNames = Arrays.asList(
|
||||||
// Note: Core recreation in Solr requires admin API calls that are typically done
|
properties.getCores().getStories(),
|
||||||
// through the Solr admin interface or by restarting with fresh cores
|
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 {
|
public void recreateIndices() throws IOException {
|
||||||
|
|||||||
Reference in New Issue
Block a user