fix #2481 add process(Map)
This commit is contained in:
parent
5f6924d6a0
commit
3631d2dddf
3 changed files with 49 additions and 6 deletions
|
@ -143,6 +143,9 @@ public class IndexUpdateCallbackImpl implements IndexUpdateCallback {
|
|||
}
|
||||
|
||||
protected Map<String, Object> ingest(final Map<String, String> paramMap, final Map<String, Object> dataMap) {
|
||||
if (ingestFactory == null) {
|
||||
return dataMap;
|
||||
}
|
||||
Map<String, Object> target = dataMap;
|
||||
for (final Ingester ingester : ingestFactory.getIngesters()) {
|
||||
try {
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
@ -48,6 +49,8 @@ import org.codelibs.fess.helper.IndexingHelper;
|
|||
import org.codelibs.fess.helper.IntervalControlHelper;
|
||||
import org.codelibs.fess.helper.SearchLogHelper;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.ingest.IngestFactory;
|
||||
import org.codelibs.fess.ingest.Ingester;
|
||||
import org.codelibs.fess.mylasta.direction.FessConfig;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.codelibs.fess.util.DocList;
|
||||
|
@ -103,10 +106,22 @@ public class IndexUpdater extends Thread {
|
|||
|
||||
private List<Crawler> crawlerList;
|
||||
|
||||
private IngestFactory ingestFactory = null;
|
||||
|
||||
public IndexUpdater() {
|
||||
// nothing
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Initialize {}", this.getClass().getSimpleName());
|
||||
}
|
||||
if (ComponentUtil.hasIngestFactory()) {
|
||||
ingestFactory = ComponentUtil.getIngestFactory();
|
||||
}
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void destroy() {
|
||||
if (!finishCrawling) {
|
||||
|
@ -356,7 +371,7 @@ public class IndexUpdater extends Thread {
|
|||
|
||||
updateDocument(map);
|
||||
|
||||
docList.add(map);
|
||||
docList.add(ingest(accessResult, map));
|
||||
final long contentSize = indexingHelper.calculateDocumentSize(map);
|
||||
docList.addContentSize(contentSize);
|
||||
final long processingTime = System.currentTimeMillis() - startTime;
|
||||
|
@ -385,6 +400,21 @@ public class IndexUpdater extends Thread {
|
|||
}
|
||||
}
|
||||
|
||||
protected Map<String, Object> ingest(final AccessResult<String> accessResult, final Map<String, Object> map) {
|
||||
if (ingestFactory == null) {
|
||||
return map;
|
||||
}
|
||||
Map<String, Object> target = map;
|
||||
for (final Ingester ingester : ingestFactory.getIngesters()) {
|
||||
try {
|
||||
target = ingester.process(target, accessResult);
|
||||
} catch (final Exception e) {
|
||||
logger.warn("Failed to process Ingest[{}]", ingester.getClass().getSimpleName(), e);
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
protected void updateDocument(final Map<String, Object> map) {
|
||||
final FessConfig fessConfig = ComponentUtil.getFessConfig();
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ package org.codelibs.fess.ingest;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import org.codelibs.fess.crawler.entity.AccessResult;
|
||||
import org.codelibs.fess.crawler.entity.ResponseData;
|
||||
import org.codelibs.fess.crawler.entity.ResultData;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
|
@ -37,14 +38,23 @@ public abstract class Ingester {
|
|||
ComponentUtil.getIngestFactory().add(this);
|
||||
}
|
||||
|
||||
// datastore
|
||||
public Map<String, Object> process(final Map<String, Object> target, final Map<String, String> params) {
|
||||
return target;
|
||||
}
|
||||
|
||||
// web/file
|
||||
public ResultData process(final ResultData target, final ResponseData responseData) {
|
||||
return target;
|
||||
}
|
||||
|
||||
// web/file
|
||||
public Map<String, Object> process(final Map<String, Object> target, final AccessResult<String> accessResult) {
|
||||
return process(target);
|
||||
}
|
||||
|
||||
// datastore
|
||||
public Map<String, Object> process(final Map<String, Object> target, final Map<String, String> params) {
|
||||
return process(target);
|
||||
}
|
||||
|
||||
protected Map<String, Object> process(final Map<String, Object> target) {
|
||||
return target;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue