Search in sources :

Example 1 with IndexingHelper

use of org.codelibs.fess.helper.IndexingHelper in project fess by codelibs.

the class FessCrawlerThread method getChildUrlSet.

protected Set<RequestData> getChildUrlSet(final FessEsClient fessEsClient, final String id) {
    final FessConfig fessConfig = ComponentUtil.getFessConfig();
    final IndexingHelper indexingHelper = ComponentUtil.getIndexingHelper();
    final List<Map<String, Object>> docList = indexingHelper.getChildDocumentList(fessEsClient, id, new String[] { fessConfig.getIndexFieldUrl() });
    if (docList.isEmpty()) {
        return null;
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Found documents: " + docList);
    }
    final Set<RequestData> urlSet = new HashSet<>(docList.size());
    for (final Map<String, Object> doc : docList) {
        final String url = DocumentUtil.getValue(doc, fessConfig.getIndexFieldUrl(), String.class);
        if (StringUtil.isNotBlank(url)) {
            urlSet.add(RequestDataBuilder.newRequestData().get().url(url).build());
        }
    }
    return urlSet;
}
Also used : IndexingHelper(org.codelibs.fess.helper.IndexingHelper) RequestData(org.codelibs.fess.crawler.entity.RequestData) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 2 with IndexingHelper

use of org.codelibs.fess.helper.IndexingHelper in project fess by codelibs.

the class FileListIndexUpdateCallbackImpl method deleteDocuments.

protected void deleteDocuments() {
    final FessEsClient fessEsClient = ComponentUtil.getFessEsClient();
    final IndexingHelper indexingHelper = ComponentUtil.getIndexingHelper();
    for (final String url : deleteUrlList) {
        indexingHelper.deleteDocumentByUrl(fessEsClient, url);
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Deleted " + deleteUrlList);
    }
    deleteUrlList.clear();
}
Also used : IndexingHelper(org.codelibs.fess.helper.IndexingHelper) FessEsClient(org.codelibs.fess.es.client.FessEsClient)

Example 3 with IndexingHelper

use of org.codelibs.fess.helper.IndexingHelper in project fess by codelibs.

the class IndexUpdateCallbackImpl method commit.

@Override
public void commit() {
    synchronized (docList) {
        if (!docList.isEmpty()) {
            final IndexingHelper indexingHelper = ComponentUtil.getIndexingHelper();
            final FessEsClient fessEsClient = ComponentUtil.getFessEsClient();
            indexingHelper.sendDocuments(fessEsClient, docList);
        }
    }
}
Also used : IndexingHelper(org.codelibs.fess.helper.IndexingHelper) FessEsClient(org.codelibs.fess.es.client.FessEsClient)

Example 4 with IndexingHelper

use of org.codelibs.fess.helper.IndexingHelper in project fess by codelibs.

the class FileListIndexUpdateCallbackImpl method deleteDocument.

protected boolean deleteDocument(final Map<String, String> paramMap, final Map<String, Object> dataMap) {
    if (logger.isDebugEnabled()) {
        logger.debug("Deleting {}", dataMap);
    }
    final FessConfig fessConfig = ComponentUtil.getFessConfig();
    // required check
    if (!dataMap.containsKey(fessConfig.getIndexFieldUrl()) || dataMap.get(fessConfig.getIndexFieldUrl()) == null) {
        logger.warn("Could not delete a doc. Invalid data: {}", dataMap);
        return false;
    }
    synchronized (indexUpdateCallback) {
        final long maxAccessCount = getMaxAccessCount(paramMap, dataMap);
        final String url = dataMap.get(fessConfig.getIndexFieldUrl()).toString();
        if (maxAccessCount != 1L) {
            final SearchEngineClient searchEngineClient = ComponentUtil.getSearchEngineClient();
            final IndexingHelper indexingHelper = ComponentUtil.getIndexingHelper();
            final long count = indexingHelper.deleteDocumentByQuery(searchEngineClient, QueryBuilders.prefixQuery(fessConfig.getIndexFieldUrl(), url));
            if (logger.isDebugEnabled()) {
                logger.debug("Deleted {} docs for {}*", count, url);
            }
        } else {
            deleteUrlList.add(url);
            if (deleteUrlList.size() >= maxDeleteDocumentCacheSize) {
                deleteDocuments();
            }
        }
    }
    return true;
}
Also used : IndexingHelper(org.codelibs.fess.helper.IndexingHelper) SearchEngineClient(org.codelibs.fess.es.client.SearchEngineClient) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig)

Example 5 with IndexingHelper

use of org.codelibs.fess.helper.IndexingHelper in project fess by codelibs.

the class IndexUpdateCallbackImpl method commit.

@Override
public void commit() {
    synchronized (docList) {
        if (!docList.isEmpty()) {
            final IndexingHelper indexingHelper = ComponentUtil.getIndexingHelper();
            final SearchEngineClient searchEngineClient = ComponentUtil.getSearchEngineClient();
            indexingHelper.sendDocuments(searchEngineClient, docList);
        }
    }
}
Also used : IndexingHelper(org.codelibs.fess.helper.IndexingHelper) SearchEngineClient(org.codelibs.fess.es.client.SearchEngineClient)

Aggregations

IndexingHelper (org.codelibs.fess.helper.IndexingHelper)11 FessConfig (org.codelibs.fess.mylasta.direction.FessConfig)7 SearchEngineClient (org.codelibs.fess.es.client.SearchEngineClient)6 HashSet (java.util.HashSet)4 HashMap (java.util.HashMap)3 LinkedHashSet (java.util.LinkedHashSet)3 Map (java.util.Map)3 RequestData (org.codelibs.fess.crawler.entity.RequestData)3 FessEsClient (org.codelibs.fess.es.client.FessEsClient)3 CrawlingInfoHelper (org.codelibs.fess.helper.CrawlingInfoHelper)3 DataStoreException (org.codelibs.fess.exception.DataStoreException)2 SystemHelper (org.codelibs.fess.helper.SystemHelper)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 Set (java.util.Set)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Collectors (java.util.stream.Collectors)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1