diff --git a/dspace-api/src/main/java/org/dspace/app/solrdatabaseresync/SolrDatabaseResyncCli.java b/dspace-api/src/main/java/org/dspace/app/solrdatabaseresync/SolrDatabaseResyncCli.java index f901c9ca569e..fb0c3a420098 100644 --- a/dspace-api/src/main/java/org/dspace/app/solrdatabaseresync/SolrDatabaseResyncCli.java +++ b/dspace-api/src/main/java/org/dspace/app/solrdatabaseresync/SolrDatabaseResyncCli.java @@ -138,7 +138,7 @@ private void performStatusUpdate(Context context) throws SearchServiceException, } } - indexingService.commit(); + indexingService.commit(true); } private void updateItem(Context context, IndexableObject indexableObject) throws SolrServerException, IOException { diff --git a/dspace-api/src/main/java/org/dspace/discovery/IndexingService.java b/dspace-api/src/main/java/org/dspace/discovery/IndexingService.java index 2ef5affa47b7..e3f5594aacc9 100644 --- a/dspace-api/src/main/java/org/dspace/discovery/IndexingService.java +++ b/dspace-api/src/main/java/org/dspace/discovery/IndexingService.java @@ -72,6 +72,8 @@ void reIndexContent(Context context, IndexableObject dso) void commit() throws SearchServiceException; + void commit(boolean hard) throws SearchServiceException; + void optimize() throws SearchServiceException; void buildSpellCheck() throws SearchServiceException, IOException; diff --git a/dspace-api/src/main/java/org/dspace/discovery/SolrServiceImpl.java b/dspace-api/src/main/java/org/dspace/discovery/SolrServiceImpl.java index 31815b36d871..ff49e4132ac0 100644 --- a/dspace-api/src/main/java/org/dspace/discovery/SolrServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/discovery/SolrServiceImpl.java @@ -222,7 +222,7 @@ public void unIndexContent(Context context, IndexableObject indexableObject, boo log.info("Try to delete uniqueID:" + uniqueID); indexObjectServiceFactory.getIndexableObjectFactory(indexableObject).delete(indexableObject); if (commit) { - solrSearchCore.getSolr().commit(false, false); + solrSearchCore.getSolr().commit(true, true); } } catch (IOException | SolrServerException exception) { log.error(exception.getMessage(), exception); @@ -263,7 +263,7 @@ public void unIndexContent(Context context, String searchUniqueID, boolean commi log.warn("Object not found in Solr index: " + searchUniqueID); } if (commit) { - solrSearchCore.getSolr().commit(false, false); + solrSearchCore.getSolr().commit(true, true); } } } catch (SolrServerException e) { @@ -1065,7 +1065,7 @@ protected DiscoverResult retrieveResult(Context context, DiscoverQuery query) log.info("ZombieDocs "); zombieDocs.forEach(log::info); solrSearchCore.getSolr().deleteById(zombieDocs); - solrSearchCore.getSolr().commit(false, false); + solrSearchCore.getSolr().commit(true, true); } else { valid = true; } @@ -1546,9 +1546,14 @@ public void indexContent(Context context, IndexableObject indexableObject, boole @Override public void commit() throws SearchServiceException { + commit(false); + } + + @Override + public void commit(boolean hard) throws SearchServiceException { try { if (solrSearchCore.getSolr() != null) { - solrSearchCore.getSolr().commit(false, false); + solrSearchCore.getSolr().commit(hard, hard); } } catch (IOException | SolrServerException e) { throw new SearchServiceException(e.getMessage(), e); diff --git a/dspace-api/src/main/java/org/dspace/statistics/SolrLoggerServiceImpl.java b/dspace-api/src/main/java/org/dspace/statistics/SolrLoggerServiceImpl.java index a3d98cc169b1..aea41e31076e 100644 --- a/dspace-api/src/main/java/org/dspace/statistics/SolrLoggerServiceImpl.java +++ b/dspace-api/src/main/java/org/dspace/statistics/SolrLoggerServiceImpl.java @@ -659,7 +659,7 @@ public boolean isUseProxies() { public void removeIndex(String query) throws IOException, SolrServerException { solr.deleteByQuery(query); - solr.commit(false, false); + solr.commit(true, true); } @Override @@ -1345,7 +1345,7 @@ public void shardSolrIndex() throws IOException, SolrServerException { //Delete contents of this year from our year query ! solr.deleteByQuery(filterQuery.toString()); - solr.commit(false, false); + solr.commit(true, true); log.info("Moved {} records into core: {}", totalRecords, coreName); } @@ -1530,7 +1530,7 @@ public void reindexBitstreamHits(boolean removeDeletedBitstreams) throws Excepti //Now that all our new bitstream stats are in place, delete all the old ones ! solr.deleteByQuery("-bundleName:[* TO *] AND type:" + Constants.BITSTREAM); //Commit everything to wrap up - solr.commit(false, false); + solr.commit(true, true); //Clean up our directory ! FileUtils.deleteDirectory(tempDirectory); } catch (Exception e) { diff --git a/dspace-api/src/test/java/org/dspace/discovery/DiscoveryIT.java b/dspace-api/src/test/java/org/dspace/discovery/DiscoveryIT.java index 55be531418ae..827c34d83cfe 100644 --- a/dspace-api/src/test/java/org/dspace/discovery/DiscoveryIT.java +++ b/dspace-api/src/test/java/org/dspace/discovery/DiscoveryIT.java @@ -829,7 +829,7 @@ private void deleteItem(Item item) throws SQLException, AuthorizeException, IOEx item = context.reloadEntity(item); itemService.delete(context, item); context.commit(); - indexer.commit(); + indexer.commit(true); context.restoreAuthSystemState(); } @@ -839,7 +839,7 @@ private void deleteSubmission(WorkspaceItem anotherWorkspaceItem) anotherWorkspaceItem = context.reloadEntity(anotherWorkspaceItem); workspaceItemService.deleteAll(context, anotherWorkspaceItem); context.commit(); - indexer.commit(); + indexer.commit(true); context.restoreAuthSystemState(); } @@ -849,7 +849,7 @@ private void deleteWorkflowItem(XmlWorkflowItem workflowItem) workflowItem = context.reloadEntity(workflowItem); workflowService.deleteWorkflowByWorkflowItem(context, workflowItem, admin); context.commit(); - indexer.commit(); + indexer.commit(true); context.restoreAuthSystemState(); } diff --git a/dspace-oai/src/main/java/org/dspace/xoai/app/XOAI.java b/dspace-oai/src/main/java/org/dspace/xoai/app/XOAI.java index b3c52e2dce09..62598b2dd9fa 100644 --- a/dspace-oai/src/main/java/org/dspace/xoai/app/XOAI.java +++ b/dspace-oai/src/main/java/org/dspace/xoai/app/XOAI.java @@ -553,7 +553,7 @@ private void clearIndex() throws DSpaceSolrIndexerException { try { System.out.println("Clearing index"); solrServerResolver.getServer().deleteByQuery("*:*"); - solrServerResolver.getServer().commit(false, false); + solrServerResolver.getServer().commit(true, true); System.out.println("Index cleared"); } catch (SolrServerException | IOException ex) { throw new DSpaceSolrIndexerException(ex.getMessage(), ex);