diff --git a/htroot/IndexReIndexMonitor_p.java b/htroot/IndexReIndexMonitor_p.java index aa477f008..ac7cb6d0f 100644 --- a/htroot/IndexReIndexMonitor_p.java +++ b/htroot/IndexReIndexMonitor_p.java @@ -164,8 +164,10 @@ public class IndexReIndexMonitor_p { } } else if(post.containsKey("simulateRecrawl")) { final SolrConnector solrConnector = sb.index.fulltext().getDefaultConnector(); - if (!solrConnector.isClosed()) { + if (solrConnector != null && !solrConnector.isClosed()) { try { + /* Ensure indexed data is up-to-date */ + solrConnector.commit(true); // query all or only httpstatus=200 depending on includefailed flag final String finalQuery = RecrawlBusyThread.buildSelectionQuery(recrawlQuery, inclerrdoc); final long count = solrConnector.getCountByQuery(finalQuery); diff --git a/source/net/yacy/crawler/RecrawlBusyThread.java b/source/net/yacy/crawler/RecrawlBusyThread.java index bfeef8e8e..bf4d145d3 100644 --- a/source/net/yacy/crawler/RecrawlBusyThread.java +++ b/source/net/yacy/crawler/RecrawlBusyThread.java @@ -129,6 +129,12 @@ public class RecrawlBusyThread extends AbstractBusyThread { // org.apache.solr.core.SolrCore java.lang.IllegalStateException: unexpected docvalues type NONE for field 'load_date_dt' (expected=NUMERIC). Use UninvertingReader or index with docvalues. this.solrSortBy = null; // CollectionSchema.load_date_dt.getSolrFieldName() + " asc"; this.chunksize = sb.getConfigInt(SwitchboardConstants.CRAWLER_THREADS_ACTIVE_MAX, 200); + + final SolrConnector solrConnector = this.sb.index.fulltext().getDefaultConnector(); + if (solrConnector != null && !solrConnector.isClosed()) { + /* Ensure indexed data is up-to-date before running the main job */ + solrConnector.commit(true); + } } /** @@ -265,7 +271,7 @@ public class RecrawlBusyThread extends AbstractBusyThread { } SolrDocumentList docList = null; final SolrConnector solrConnector = sb.index.fulltext().getDefaultConnector(); - if (solrConnector.isClosed()) { + if (solrConnector == null || solrConnector.isClosed()) { this.urlsToRecrawl = 0; this.terminatedBySolrFailure = true; return false;