@@ -193,9 +193,9 @@ private int index(Instant last) throws DSpaceSolrIndexerException, IOException {
193193 .findInArchiveOrWithdrawnDiscoverableModifiedSince (context , last );
194194 Iterator <Item > nonDiscoverableChangedItems = itemService
195195 .findInArchiveOrWithdrawnNonDiscoverableModifiedSince (context , last );
196+ int total = this .index (discoverableChangedItems , true ) + this .index (nonDiscoverableChangedItems , true );
196197 Iterator <Item > possiblyChangedItems = getItemsWithPossibleChangesBefore (last );
197- return this .index (discoverableChangedItems ) + this .index (nonDiscoverableChangedItems )
198- + this .index (possiblyChangedItems );
198+ return total + this .index (possiblyChangedItems , false );
199199 } catch (SQLException ex ) {
200200 throw new DSpaceSolrIndexerException (ex .getMessage (), ex );
201201 }
@@ -266,7 +266,7 @@ private int indexAll() throws DSpaceSolrIndexerException {
266266 null );
267267 Iterator <Item > nonDiscoverableItems = itemService
268268 .findInArchiveOrWithdrawnNonDiscoverableModifiedSince (context , null );
269- return this .index (discoverableItems ) + this .index (nonDiscoverableItems );
269+ return this .index (discoverableItems , true ) + this .index (nonDiscoverableItems , true );
270270 } catch (SQLException ex ) {
271271 throw new DSpaceSolrIndexerException (ex .getMessage (), ex );
272272 }
@@ -309,7 +309,7 @@ private boolean checkIfVisibleInOAI(Item item) throws IOException {
309309 }
310310 }
311311
312- private int index (Iterator <Item > iterator ) throws DSpaceSolrIndexerException {
312+ private int index (Iterator <Item > iterator , boolean uncacheEntities ) throws DSpaceSolrIndexerException {
313313 try {
314314 int i = 0 ;
315315 int batchSize = configurationService .getIntProperty ("oai.import.batch.size" , 1000 );
@@ -338,10 +338,12 @@ private int index(Iterator<Item> iterator) throws DSpaceSolrIndexerException {
338338 server .add (list );
339339 server .commit ();
340340 list .clear ();
341- try {
342- context .uncacheEntities ();
343- } catch (SQLException ex ) {
344- log .error ("Error uncaching entities" , ex );
341+ if (uncacheEntities ) {
342+ try {
343+ context .uncacheEntities ();
344+ } catch (SQLException ex ) {
345+ log .error ("Error uncaching entities" , ex );
346+ }
345347 }
346348 }
347349 }
0 commit comments