/** * 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; }
/** * Check the command line options and rebuild the spell check if active. * * @param line the command line options * @param indexer the solr indexer * @throws SearchServiceException in case of a solr exception */ protected static void checkRebuildSpellCheck(CommandLine line, IndexingService indexer) throws SearchServiceException { if (line.hasOption("s")) { log.info("Rebuilding spell checker."); indexer.buildSpellCheck(); } } }
indexer.unIndexContent(context, line.getOptionValue("r")); } else if (line.hasOption("c")) { log.info("Cleaning Index"); indexer.cleanIndex(line.hasOption("f")); } else if (line.hasOption("b")) { log.info("(Re)building index from scratch."); indexer.createIndex(context); } else if (line.hasOption("o")) { log.info("Optimizing search core."); indexer.optimize(); } else { log.info("Updating and Cleaning Index"); indexer.cleanIndex(line.hasOption("f")); indexer.updateIndex(context, line.hasOption("f"));
this.indexer.cleanIndex(true); this.indexer.createIndex(context); this.indexer.buildSpellCheck();
if (hdl != null && !handlesToDelete.contains(hdl)) { try { indexer.indexContent(ctx, iu, true); log.debug("Indexed " + Constants.typeText[iu.getType()] indexer.unIndexContent(ctx, hdl, true); if (log.isDebugEnabled())
long count = 0; indexingService.indexContent(context, dso, true, true); count++; if (dso.getType() == Constants.COMMUNITY) { for (final Collection collection : reloadedCommunity.getCollections()) { count++; indexingService.indexContent(context, collection, true, true); count += indexItems(indexingService, itemService, context, collection);
indexer.unIndexContent(context, line.getOptionValue("r")); } else if (line.hasOption("c")) { log.info("Cleaning Index"); indexer.cleanIndex(line.hasOption("f")); } else if (line.hasOption("b")) { log.info("(Re)building index from scratch."); indexer.createIndex(context); checkRebuildSpellCheck(line, indexer); } else if (line.hasOption("o")) { log.info("Optimizing search core."); indexer.optimize(); } else if (line.hasOption('s')) { checkRebuildSpellCheck(line, indexer); } else { log.info("Updating and Cleaning Index"); indexer.cleanIndex(line.hasOption("f")); indexer.updateIndex(context, line.hasOption("f")); checkRebuildSpellCheck(line, indexer);
if (hdl != null && !handlesToDelete.contains(hdl)) { try { indexer.indexContent(ctx, iu, true); log.debug("Indexed " + Constants.typeText[iu.getType()] indexer.unIndexContent(ctx, hdl, true); if (log.isDebugEnabled()) { log.debug("UN-Indexed Item, handle=" + hdl);