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;
}
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;
}
Aggregations