Search in sources :

Example 1 with MCRSolrFileIndexHandler

use of org.mycore.solr.index.handlers.stream.MCRSolrFileIndexHandler 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)

Example 2 with MCRSolrFileIndexHandler

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

the class MCRSolrIndexHandlerFactory method getIndexHandler.

public MCRSolrIndexHandler getIndexHandler(Path file, BasicFileAttributes attrs, SolrClient solrClient, boolean sendContent) throws IOException {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Solr: submitting file \"{} for indexing", file);
    }
    MCRSolrIndexHandler indexHandler;
    long start = System.currentTimeMillis();
    if (sendContent) {
        /* extract metadata with tika */
        indexHandler = new MCRSolrFileIndexHandler(file, attrs, solrClient);
    } else {
        SolrInputDocument doc = MCRSolrPathDocumentFactory.getInstance().getDocument(file, attrs);
        indexHandler = new MCRSolrInputDocumentHandler(doc, solrClient);
    }
    long end = System.currentTimeMillis();
    indexHandler.getStatistic().addTime(end - start);
    return indexHandler;
}
Also used : SolrInputDocument(org.apache.solr.common.SolrInputDocument) MCRSolrFileIndexHandler(org.mycore.solr.index.handlers.stream.MCRSolrFileIndexHandler) MCRSolrIndexHandler(org.mycore.solr.index.MCRSolrIndexHandler) MCRSolrInputDocumentHandler(org.mycore.solr.index.handlers.document.MCRSolrInputDocumentHandler)

Aggregations

SolrInputDocument (org.apache.solr.common.SolrInputDocument)2 MCRSolrFileIndexHandler (org.mycore.solr.index.handlers.stream.MCRSolrFileIndexHandler)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 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 MCRSolrIndexHandler (org.mycore.solr.index.MCRSolrIndexHandler)1 MCRSolrIndexHandlerFactory (org.mycore.solr.index.handlers.MCRSolrIndexHandlerFactory)1 MCRSolrInputDocumentHandler (org.mycore.solr.index.handlers.document.MCRSolrInputDocumentHandler)1 MCRSolrFilesIndexHandler (org.mycore.solr.index.handlers.stream.MCRSolrFilesIndexHandler)1