diff --git a/src/main/java/org/codelibs/fess/helper/SuggestHelper.java b/src/main/java/org/codelibs/fess/helper/SuggestHelper.java index d5a0cff52..6e0c0459a 100644 --- a/src/main/java/org/codelibs/fess/helper/SuggestHelper.java +++ b/src/main/java/org/codelibs/fess/helper/SuggestHelper.java @@ -48,8 +48,11 @@ import org.codelibs.fess.suggest.index.contents.document.ESSourceReader; import org.codelibs.fess.suggest.settings.SuggestSettings; import org.codelibs.fess.suggest.util.SuggestUtil; import org.codelibs.fess.util.ComponentUtil; +import org.elasticsearch.common.lucene.search.function.CombineFunction; import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.index.query.functionscore.FunctionScoreQueryBuilder; +import org.elasticsearch.index.query.functionscore.ScoreFunctionBuilders; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -151,7 +154,16 @@ public class SuggestHelper { final ESSourceReader reader = new ESSourceReader(fessEsClient, suggester.settings(), fessConfig.getIndexDocumentSearchIndex(), fessConfig.getIndexDocumentType()); - reader.setScrollSize(fessConfig.getSuggestSourceReaderScrollSizeAsInteger().intValue()); + reader.setScrollSize(fessConfig.getSuggestSourceReaderScrollSizeAsInteger()); + reader.setLimitDocNumPercentage(fessConfig.getSuggestUpdateContentsLimitNumPercentage()); + reader.setLimitNumber(fessConfig.getSuggestUpdateContentsLimitNumAsInteger()); + + final List 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)); return reader; }, 2, fessConfig.getSuggestUpdateRequestIntervalAsInteger().longValue()).then(response -> { suggester.refresh(); @@ -305,5 +317,4 @@ public class SuggestHelper { public void deleteBadWord(final String badWord) { suggester.indexer().deleteBadWord(badWord); } - } diff --git a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java index 22ae15658..7d216dc22 100644 --- a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java +++ b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java @@ -855,6 +855,12 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction /** The key of the configuration. e.g. 1 */ String SUGGEST_UPDATE_REQUEST_INTERVAL = "suggest.update.request.interval"; + /** The key of the configuration. e.g. 50% */ + String SUGGEST_UPDATE_CONTENTS_LIMIT_NUM_PERCENTAGE = "suggest.update.contents.limit.num.percentage"; + + /** The key of the configuration. e.g. 10000 */ + String SUGGEST_UPDATE_CONTENTS_LIMIT_NUM = "suggest.update.contents.limit.num"; + /** The key of the configuration. e.g. 1 */ String SUGGEST_SOURCE_READER_SCROLL_SIZE = "suggest.source.reader.scroll.size"; @@ -3798,6 +3804,28 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction */ Integer getSuggestUpdateRequestIntervalAsInteger(); + /** + * Get the value for the key 'suggest.update.contents.limit.num.percentage'.
+ * The value is, e.g. 50%
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + */ + String getSuggestUpdateContentsLimitNumPercentage(); + + /** + * Get the value for the key 'suggest.update.contents.limit.num'.
+ * The value is, e.g. 10000
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + */ + String getSuggestUpdateContentsLimitNum(); + + /** + * Get the value for the key 'suggest.update.contents.limit.num' as {@link Integer}.
+ * The value is, e.g. 10000
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + * @throws NumberFormatException When the property is not integer. + */ + Integer getSuggestUpdateContentsLimitNumAsInteger(); + /** * Get the value for the key 'suggest.source.reader.scroll.size'.
* The value is, e.g. 1
@@ -5880,6 +5908,18 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction return getAsInteger(FessConfig.SUGGEST_UPDATE_REQUEST_INTERVAL); } + public String getSuggestUpdateContentsLimitNumPercentage() { + return get(FessConfig.SUGGEST_UPDATE_CONTENTS_LIMIT_NUM_PERCENTAGE); + } + + public String getSuggestUpdateContentsLimitNum() { + return get(FessConfig.SUGGEST_UPDATE_CONTENTS_LIMIT_NUM); + } + + public Integer getSuggestUpdateContentsLimitNumAsInteger() { + return getAsInteger(FessConfig.SUGGEST_UPDATE_CONTENTS_LIMIT_NUM); + } + public String getSuggestSourceReaderScrollSize() { return get(FessConfig.SUGGEST_SOURCE_READER_SCROLL_SIZE); } diff --git a/src/main/resources/fess_config.properties b/src/main/resources/fess_config.properties index e2cdf5967..bd94b8842 100644 --- a/src/main/resources/fess_config.properties +++ b/src/main/resources/fess_config.properties @@ -438,6 +438,8 @@ suggest.field.tags=label suggest.field.roles=role suggest.field.index.contents=content,title suggest.update.request.interval=1 +suggest.update.contents.limit.num.percentage=50% +suggest.update.contents.limit.num=10000 suggest.source.reader.scroll.size=1 suggest.popular.word.cache.size=1000 suggest.popular.word.cache.expire=60