fix series number and improve author view

This commit is contained in:
Stefan Hardegger
2026-07-20 12:51:20 +02:00
parent ddfc5aef99
commit d910ad8fa8
4 changed files with 79 additions and 27 deletions

View File

@@ -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());
}
}
}