fix series number and improve author view
This commit is contained in:
@@ -1394,6 +1394,10 @@ public class SolrService {
|
||||
}
|
||||
|
||||
public void recreateCores() throws IOException {
|
||||
if (!isAvailable()) {
|
||||
throw new IOException("Solr is not available");
|
||||
}
|
||||
|
||||
List<String> coreNames = Arrays.asList(
|
||||
properties.getCores().getStories(),
|
||||
properties.getCores().getAuthors(),
|
||||
@@ -1403,20 +1407,13 @@ public class SolrService {
|
||||
for (String coreName : coreNames) {
|
||||
try {
|
||||
logger.info("Clearing Lucene index for core: {}", coreName);
|
||||
|
||||
// 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, false, solrClient);
|
||||
logger.info("Unloaded core (index deleted): {}", 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 clear/reload core {} (may not exist yet): {}", coreName, e.getMessage());
|
||||
// Delete all documents and hard-commit so the index is empty immediately.
|
||||
// Using deleteByQuery keeps the core registered in Solr — no restart needed.
|
||||
solrClient.deleteByQuery(coreName, "*:*");
|
||||
solrClient.commit(coreName);
|
||||
logger.info("Successfully cleared index for core: {}", coreName);
|
||||
} catch (Exception e) {
|
||||
logger.warn("Could not clear core {} (may not exist yet): {}", coreName, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user