Search in sources :

Example 1 with MCRSolrFilesIndexHandler

use of org.mycore.solr.index.handlers.stream.MCRSolrFilesIndexHandler in project mycore by MyCoRe-Org.

the class MCRSolrIndexer method rebuildContentIndex.

/**
 * Rebuilds solr's content index.
 *
 * @param solrClient
 *            solr client connection
 * @param list
 *            list of mycore object id's
 * @param priority
 *            higher priority means earlier execution
 */
public static void rebuildContentIndex(SolrClient solrClient, List<String> list, int priority) {
    LOGGER.info("Re-building Content Index");
    if (list.isEmpty()) {
        LOGGER.info("No objects to index");
        return;
    }
    long tStart = System.currentTimeMillis();
    int totalCount = list.size();
    LOGGER.info("Sending content of {} derivates to solr for reindexing", totalCount);
    for (String id : list) {
        MCRSolrFilesIndexHandler indexHandler = new MCRSolrFilesIndexHandler(id, solrClient);
        indexHandler.setCommitWithin(BATCH_AUTO_COMMIT_WITHIN_MS);
        submitIndexHandler(indexHandler, priority);
    }
    long tStop = System.currentTimeMillis();
    MCRSolrIndexStatisticCollector.FILE_TRANSFER.addTime(tStop - tStart);
}
Also used : MCRSolrFilesIndexHandler(org.mycore.solr.index.handlers.stream.MCRSolrFilesIndexHandler)

Example 2 with MCRSolrFilesIndexHandler

use of org.mycore.solr.index.handlers.stream.MCRSolrFilesIndexHandler in project mycore by MyCoRe-Org.

the class MCRSolrPathDocumentFactory method getDocument.

/**
 * Generates a {@link SolrInputDocument} from a {@link MCRPath} instance.
 *
 * @see MCRSolrFileIndexHandler
 * @see MCRSolrFilesIndexHandler
 * @see MCRSolrIndexHandlerFactory
 */
public SolrInputDocument getDocument(Path input, BasicFileAttributes attr) throws IOException, MCRPersistenceException {
    SolrInputDocument doc = new SolrInputDocument();
    Consumer<? super MCRSolrFileIndexAccumulator> accumulate = (accumulator) -> {
        LOGGER.debug("{} accumulates {}", accumulator, input);
        try {
            accumulator.accumulate(doc, input, attr);
        } catch (IOException e) {
            LOGGER.error("Error in Accumulator!", e);
        }
    };
    ACCUMULATOR_LIST.forEach(accumulate);
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("MCRFile {} transformed to:\n{}", input, doc);
    }
    return doc;
}
Also used : MCRSolrFilesIndexHandler(org.mycore.solr.index.handlers.stream.MCRSolrFilesIndexHandler) MCRPath(org.mycore.datamodel.niofs.MCRPath) MCRPersistenceException(org.mycore.common.MCRPersistenceException) IOException(java.io.IOException) MCRConfiguration(org.mycore.common.config.MCRConfiguration) MCRSolrFileIndexHandler(org.mycore.solr.index.handlers.stream.MCRSolrFileIndexHandler) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes) Collectors(java.util.stream.Collectors) MCRConfigurationException(org.mycore.common.config.MCRConfigurationException) Consumer(java.util.function.Consumer) List(java.util.List) Logger(org.apache.logging.log4j.Logger) CONFIG_PREFIX(org.mycore.solr.MCRSolrConstants.CONFIG_PREFIX) MCRSolrIndexHandlerFactory(org.mycore.solr.index.handlers.MCRSolrIndexHandlerFactory) Path(java.nio.file.Path) LogManager(org.apache.logging.log4j.LogManager) SolrInputDocument(org.apache.solr.common.SolrInputDocument) SolrInputDocument(org.apache.solr.common.SolrInputDocument) IOException(java.io.IOException)

Aggregations

MCRSolrFilesIndexHandler (org.mycore.solr.index.handlers.stream.MCRSolrFilesIndexHandler)2 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 BasicFileAttributes (java.nio.file.attribute.BasicFileAttributes)1 List (java.util.List)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 SolrInputDocument (org.apache.solr.common.SolrInputDocument)1 MCRPersistenceException (org.mycore.common.MCRPersistenceException)1 MCRConfiguration (org.mycore.common.config.MCRConfiguration)1 MCRConfigurationException (org.mycore.common.config.MCRConfigurationException)1 MCRPath (org.mycore.datamodel.niofs.MCRPath)1 CONFIG_PREFIX (org.mycore.solr.MCRSolrConstants.CONFIG_PREFIX)1 MCRSolrIndexHandlerFactory (org.mycore.solr.index.handlers.MCRSolrIndexHandlerFactory)1 MCRSolrFileIndexHandler (org.mycore.solr.index.handlers.stream.MCRSolrFileIndexHandler)1