From adf34e3d8394225d9539edd154f2691f4aa8d177 Mon Sep 17 00:00:00 2001
From: Shinsuke Sugaya <shinsuke@apache.org>
Date: Thu, 22 Mar 2018 17:32:46 +0900
Subject: [PATCH] fix #1576 add suggest.update.contents.limit.doc.size

---
 .../codelibs/fess/helper/SuggestHelper.java   |  1 +
 .../fess/mylasta/direction/FessConfig.java    | 27 +++++++++++++++++++
 src/main/resources/fess_config.properties     |  1 +
 3 files changed, 29 insertions(+)

diff --git a/src/main/java/org/codelibs/fess/helper/SuggestHelper.java b/src/main/java/org/codelibs/fess/helper/SuggestHelper.java
index 84e895bce..01aa18e6e 100644
--- a/src/main/java/org/codelibs/fess/helper/SuggestHelper.java
+++ b/src/main/java/org/codelibs/fess/helper/SuggestHelper.java
@@ -199,6 +199,7 @@ public class SuggestHelper {
                             reader.setScrollSize(fessConfig.getSuggestSourceReaderScrollSizeAsInteger());
                             reader.setLimitDocNumPercentage(fessConfig.getSuggestUpdateContentsLimitNumPercentage());
                             reader.setLimitNumber(fessConfig.getSuggestUpdateContentsLimitNumAsInteger());
+                            reader.setLimitOfDocumentSize(fessConfig.getSuggestUpdateContentsLimitDocSizeAsInteger());
 
                             final List<FunctionScoreQueryBuilder.FilterFunctionBuilder> flist = new ArrayList<>();
                             flist.add(new FunctionScoreQueryBuilder.FilterFunctionBuilder(ScoreFunctionBuilders.randomFunction()
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 e70c8eee1..b27d6f20f 100644
--- a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java
+++ b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java
@@ -1123,6 +1123,9 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
     /** 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. 50000 */
+    String SUGGEST_UPDATE_CONTENTS_LIMIT_DOC_SIZE = "suggest.update.contents.limit.doc.size";
+
     /** The key of the configuration. e.g. 1 */
     String SUGGEST_SOURCE_READER_SCROLL_SIZE = "suggest.source.reader.scroll.size";
 
@@ -4970,6 +4973,21 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
      */
     Integer getSuggestUpdateContentsLimitNumAsInteger();
 
+    /**
+     * Get the value for the key 'suggest.update.contents.limit.doc.size'. <br>
+     * The value is, e.g. 50000 <br>
+     * @return The value of found property. (NotNull: if not found, exception but basically no way)
+     */
+    String getSuggestUpdateContentsLimitDocSize();
+
+    /**
+     * Get the value for the key 'suggest.update.contents.limit.doc.size' as {@link Integer}. <br>
+     * The value is, e.g. 50000 <br>
+     * @return The value of found property. (NotNull: if not found, exception but basically no way)
+     * @throws NumberFormatException When the property is not integer.
+     */
+    Integer getSuggestUpdateContentsLimitDocSizeAsInteger();
+
     /**
      * Get the value for the key 'suggest.source.reader.scroll.size'. <br>
      * The value is, e.g. 1 <br>
@@ -7527,6 +7545,14 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
             return getAsInteger(FessConfig.SUGGEST_UPDATE_CONTENTS_LIMIT_NUM);
         }
 
+        public String getSuggestUpdateContentsLimitDocSize() {
+            return get(FessConfig.SUGGEST_UPDATE_CONTENTS_LIMIT_DOC_SIZE);
+        }
+
+        public Integer getSuggestUpdateContentsLimitDocSizeAsInteger() {
+            return getAsInteger(FessConfig.SUGGEST_UPDATE_CONTENTS_LIMIT_DOC_SIZE);
+        }
+
         public String getSuggestSourceReaderScrollSize() {
             return get(FessConfig.SUGGEST_SOURCE_READER_SCROLL_SIZE);
         }
@@ -8242,6 +8268,7 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
             defaultMap.put(FessConfig.SUGGEST_UPDATE_REQUEST_INTERVAL, "1");
             defaultMap.put(FessConfig.SUGGEST_UPDATE_CONTENTS_LIMIT_NUM_PERCENTAGE, "50%");
             defaultMap.put(FessConfig.SUGGEST_UPDATE_CONTENTS_LIMIT_NUM, "10000");
+            defaultMap.put(FessConfig.SUGGEST_UPDATE_CONTENTS_LIMIT_DOC_SIZE, "50000");
             defaultMap.put(FessConfig.SUGGEST_SOURCE_READER_SCROLL_SIZE, "1");
             defaultMap.put(FessConfig.SUGGEST_POPULAR_WORD_CACHE_SIZE, "1000");
             defaultMap.put(FessConfig.SUGGEST_POPULAR_WORD_CACHE_EXPIRE, "60");
diff --git a/src/main/resources/fess_config.properties b/src/main/resources/fess_config.properties
index 45b546f4f..9340a9e03 100644
--- a/src/main/resources/fess_config.properties
+++ b/src/main/resources/fess_config.properties
@@ -572,6 +572,7 @@ 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.update.contents.limit.doc.size=50000
 suggest.source.reader.scroll.size=1
 suggest.popular.word.cache.size=1000
 suggest.popular.word.cache.expire=60
-- 
GitLab