Search in sources :

Example 1 with ThumbnailManager

use of org.codelibs.fess.thumbnail.ThumbnailManager in project fess by codelibs.

the class IndexingHelper method sendDocuments.

public void sendDocuments(final FessEsClient fessEsClient, final DocList docList) {
    if (docList.isEmpty()) {
        return;
    }
    final FessConfig fessConfig = ComponentUtil.getFessConfig();
    if (fessConfig.isResultCollapsed()) {
        docList.forEach(doc -> {
            doc.put("content_minhash", doc.get(fessConfig.getIndexFieldContent()));
        });
    }
    final long execTime = System.currentTimeMillis();
    if (logger.isDebugEnabled()) {
        logger.debug("Sending " + docList.size() + " documents to a server.");
    }
    try {
        if (fessConfig.isThumbnailCrawlerEnabled()) {
            final ThumbnailManager thumbnailManager = ComponentUtil.getThumbnailManager();
            docList.stream().forEach(doc -> thumbnailManager.offer(doc));
        }
        synchronized (fessEsClient) {
            deleteOldDocuments(fessEsClient, docList);
            fessEsClient.addAll(fessConfig.getIndexDocumentUpdateIndex(), fessConfig.getIndexDocumentType(), docList);
        }
        if (logger.isInfoEnabled()) {
            if (docList.getContentSize() > 0) {
                logger.info("Sent " + docList.size() + " docs (Doc:{process " + docList.getProcessingTime() + "ms, send " + (System.currentTimeMillis() - execTime) + "ms, size " + MemoryUtil.byteCountToDisplaySize(docList.getContentSize()) + "}, " + MemoryUtil.getMemoryUsageLog() + ")");
            } else {
                logger.info("Sent " + docList.size() + " docs (Doc:{send " + (System.currentTimeMillis() - execTime) + "ms}, " + MemoryUtil.getMemoryUsageLog() + ")");
            }
        }
    } finally {
        docList.clear();
    }
}
Also used : ThumbnailManager(org.codelibs.fess.thumbnail.ThumbnailManager) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig)

Aggregations

FessConfig (org.codelibs.fess.mylasta.direction.FessConfig)1 ThumbnailManager (org.codelibs.fess.thumbnail.ThumbnailManager)1