use of org.codelibs.fess.app.service.KeyMatchService in project fess by codelibs.
the class KeyMatchHelper method reload.
protected void reload(final long interval) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final KeyMatchService keyMatchService = ComponentUtil.getComponent(KeyMatchService.class);
final Map<String, Pair<QueryBuilder, ScoreFunctionBuilder>> keyMatchQueryMap = new HashMap<>();
keyMatchService.getAvailableKeyMatchList().stream().forEach(keyMatch -> {
final BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
getDocumentList(keyMatch).stream().map(doc -> {
return DocumentUtil.getValue(doc, fessConfig.getIndexFieldDocId(), String.class);
}).forEach(docId -> {
boolQuery.should(QueryBuilders.termQuery(fessConfig.getIndexFieldDocId(), docId));
});
if (boolQuery.hasClauses()) {
keyMatchQueryMap.put(toLowerCase(keyMatch.getTerm()), new Pair<>(boolQuery, ScoreFunctionBuilders.weightFactorFunction(keyMatch.getBoost())));
}
if (reloadInterval > 0) {
try {
Thread.sleep(reloadInterval);
} catch (final InterruptedException e) {
if (logger.isDebugEnabled()) {
logger.debug("Interrupted.", e);
}
}
}
});
this.keyMatchQueryMap = keyMatchQueryMap;
}
Aggregations