/** * Indexes all items in the given collection. * * @param indexingService * @param itemService * @param context The relevant DSpace Context. * @param collection collection to index * @throws IOException A general class of exceptions produced by failed or interrupted I/O operations. * @throws SearchServiceException in case of a solr exception * @throws SQLException An exception that provides information on a database access error or other errors. */ private static long indexItems(final IndexingService indexingService, final ItemService itemService, final Context context, final Collection collection) throws IOException, SearchServiceException, SQLException { long count = 0; final Iterator<Item> itemIterator = itemService.findByCollection(context, collection); while (itemIterator.hasNext()) { Item item = itemIterator.next(); indexingService.indexContent(context, item, true, false); count++; //To prevent memory issues, discard an object from the cache after processing context.uncacheEntity(item); } indexingService.commit(); return count; }