use of org.codelibs.fess.suggest.index.contents.document.ESSourceReader in project fess by codelibs.
the class SuggestHelper method indexFromDocuments.
public void indexFromDocuments(final Consumer<Boolean> success, final Consumer<Throwable> error) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
suggester.indexer().indexFromDocument(() -> {
final ESSourceReader reader = new ESSourceReader(fessEsClient, suggester.settings(), fessConfig.getIndexDocumentSearchIndex(), fessConfig.getIndexDocumentType());
reader.setScrollSize(fessConfig.getSuggestSourceReaderScrollSizeAsInteger());
reader.setLimitDocNumPercentage(fessConfig.getSuggestUpdateContentsLimitNumPercentage());
reader.setLimitNumber(fessConfig.getSuggestUpdateContentsLimitNumAsInteger());
final List<FunctionScoreQueryBuilder.FilterFunctionBuilder> flist = new ArrayList<>();
flist.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(ScoreFunctionBuilders.randomFunction(System.currentTimeMillis())));
reader.setQuery(QueryBuilders.functionScoreQuery(QueryBuilders.matchAllQuery(), flist.toArray(new FunctionScoreQueryBuilder.FilterFunctionBuilder[flist.size()])).boostMode(CombineFunction.MULTIPLY));
reader.addSort(SortBuilders.fieldSort(fessConfig.getIndexFieldClickCount()));
reader.addSort(SortBuilders.scoreSort());
return reader;
}, 2, fessConfig.getSuggestUpdateRequestIntervalAsInteger().longValue()).then(response -> {
suggester.refresh();
success.accept(true);
}).error(t -> error.accept(t));
}
Aggregations