Преглед изворни кода

fix #1971 add searchlog.agg.shard.size

Shinsuke Sugaya пре 6 година
родитељ
комит
c8f033eb3c

+ 12 - 0
src/main/java/org/codelibs/fess/app/service/SearchLogService.java

@@ -119,6 +119,9 @@ public class SearchLogService {
                 createClickLogCondition(pager, cb);
                 createClickLogCondition(pager, cb);
                 cb.aggregation().setUrl_Terms(SearchLogPager.LOG_TYPE_CLICK_COUNT, op -> {
                 cb.aggregation().setUrl_Terms(SearchLogPager.LOG_TYPE_CLICK_COUNT, op -> {
                     op.size(pager.getPageSize());
                     op.size(pager.getPageSize());
+                    if (fessConfig.getSearchlogAggShardSizeAsInteger() >= 0) {
+                        op.shardSize(fessConfig.getSearchlogAggShardSizeAsInteger());
+                    }
                 }, null);
                 }, null);
             });
             });
             final Terms agg = list.getAggregations().get(SearchLogPager.LOG_TYPE_CLICK_COUNT);
             final Terms agg = list.getAggregations().get(SearchLogPager.LOG_TYPE_CLICK_COUNT);
@@ -143,6 +146,9 @@ public class SearchLogService {
                 createFavoriteLogCondition(pager, cb);
                 createFavoriteLogCondition(pager, cb);
                 cb.aggregation().setUrl_Terms(SearchLogPager.LOG_TYPE_FAVORITE_COUNT, op -> {
                 cb.aggregation().setUrl_Terms(SearchLogPager.LOG_TYPE_FAVORITE_COUNT, op -> {
                     op.size(pager.getPageSize());
                     op.size(pager.getPageSize());
+                    if (fessConfig.getSearchlogAggShardSizeAsInteger() >= 0) {
+                        op.shardSize(fessConfig.getSearchlogAggShardSizeAsInteger());
+                    }
                 }, null);
                 }, null);
             });
             });
             final Terms agg = list.getAggregations().get(SearchLogPager.LOG_TYPE_FAVORITE_COUNT);
             final Terms agg = list.getAggregations().get(SearchLogPager.LOG_TYPE_FAVORITE_COUNT);
@@ -289,6 +295,9 @@ public class SearchLogService {
                 createSearchLogCondition(pager, cb);
                 createSearchLogCondition(pager, cb);
                 cb.aggregation().setSearchWord_Terms(SearchLogPager.LOG_TYPE_SEARCH_KEYWORD, op -> {
                 cb.aggregation().setSearchWord_Terms(SearchLogPager.LOG_TYPE_SEARCH_KEYWORD, op -> {
                     op.size(pager.getPageSize());
                     op.size(pager.getPageSize());
+                    if (fessConfig.getSearchlogAggShardSizeAsInteger() >= 0) {
+                        op.shardSize(fessConfig.getSearchlogAggShardSizeAsInteger());
+                    }
                 }, null);
                 }, null);
             });
             });
             final Terms agg = list.getAggregations().get(SearchLogPager.LOG_TYPE_SEARCH_KEYWORD);
             final Terms agg = list.getAggregations().get(SearchLogPager.LOG_TYPE_SEARCH_KEYWORD);
@@ -308,6 +317,9 @@ public class SearchLogService {
                 cb.query().setHitCount_Equal(0L);
                 cb.query().setHitCount_Equal(0L);
                 cb.aggregation().setSearchWord_Terms(SearchLogPager.LOG_TYPE_SEARCH_ZEROHIT, op -> {
                 cb.aggregation().setSearchWord_Terms(SearchLogPager.LOG_TYPE_SEARCH_ZEROHIT, op -> {
                     op.size(pager.getPageSize());
                     op.size(pager.getPageSize());
+                    if (fessConfig.getSearchlogAggShardSizeAsInteger() >= 0) {
+                        op.shardSize(fessConfig.getSearchlogAggShardSizeAsInteger());
+                    }
                 }, null);
                 }, null);
             });
             });
             final Terms agg = list.getAggregations().get(SearchLogPager.LOG_TYPE_SEARCH_ZEROHIT);
             final Terms agg = list.getAggregations().get(SearchLogPager.LOG_TYPE_SEARCH_ZEROHIT);

+ 27 - 0
src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java

@@ -926,6 +926,9 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
     /** The key of the configuration. e.g. 100 */
     /** The key of the configuration. e.g. 100 */
     String PAGING_SEARCH_PAGE_MAX_SIZE = "paging.search.page.max.size";
     String PAGING_SEARCH_PAGE_MAX_SIZE = "paging.search.page.max.size";
 
 
+    /** The key of the configuration. e.g. -1 */
+    String SEARCHLOG_AGG_SHARD_SIZE = "searchlog.agg.shard.size";
+
     /** The key of the configuration. e.g. 100 */
     /** The key of the configuration. e.g. 100 */
     String THUMBNAIL_HTML_IMAGE_MIN_WIDTH = "thumbnail.html.image.min.width";
     String THUMBNAIL_HTML_IMAGE_MIN_WIDTH = "thumbnail.html.image.min.width";
 
 
@@ -4423,6 +4426,21 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
      */
      */
     Integer getPagingSearchPageMaxSizeAsInteger();
     Integer getPagingSearchPageMaxSizeAsInteger();
 
 
+    /**
+     * Get the value for the key 'searchlog.agg.shard.size'. <br>
+     * The value is, e.g. -1 <br>
+     * @return The value of found property. (NotNull: if not found, exception but basically no way)
+     */
+    String getSearchlogAggShardSize();
+
+    /**
+     * Get the value for the key 'searchlog.agg.shard.size' as {@link Integer}. <br>
+     * The value is, e.g. -1 <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 getSearchlogAggShardSizeAsInteger();
+
     /**
     /**
      * Get the value for the key 'thumbnail.html.image.min.width'. <br>
      * Get the value for the key 'thumbnail.html.image.min.width'. <br>
      * The value is, e.g. 100 <br>
      * The value is, e.g. 100 <br>
@@ -7462,6 +7480,14 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
             return getAsInteger(FessConfig.PAGING_SEARCH_PAGE_MAX_SIZE);
             return getAsInteger(FessConfig.PAGING_SEARCH_PAGE_MAX_SIZE);
         }
         }
 
 
+        public String getSearchlogAggShardSize() {
+            return get(FessConfig.SEARCHLOG_AGG_SHARD_SIZE);
+        }
+
+        public Integer getSearchlogAggShardSizeAsInteger() {
+            return getAsInteger(FessConfig.SEARCHLOG_AGG_SHARD_SIZE);
+        }
+
         public String getThumbnailHtmlImageMinWidth() {
         public String getThumbnailHtmlImageMinWidth() {
             return get(FessConfig.THUMBNAIL_HTML_IMAGE_MIN_WIDTH);
             return get(FessConfig.THUMBNAIL_HTML_IMAGE_MIN_WIDTH);
         }
         }
@@ -8563,6 +8589,7 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction
             defaultMap.put(FessConfig.PAGING_SEARCH_PAGE_START, "0");
             defaultMap.put(FessConfig.PAGING_SEARCH_PAGE_START, "0");
             defaultMap.put(FessConfig.PAGING_SEARCH_PAGE_SIZE, "10");
             defaultMap.put(FessConfig.PAGING_SEARCH_PAGE_SIZE, "10");
             defaultMap.put(FessConfig.PAGING_SEARCH_PAGE_MAX_SIZE, "100");
             defaultMap.put(FessConfig.PAGING_SEARCH_PAGE_MAX_SIZE, "100");
+            defaultMap.put(FessConfig.SEARCHLOG_AGG_SHARD_SIZE, "-1");
             defaultMap.put(FessConfig.THUMBNAIL_HTML_IMAGE_MIN_WIDTH, "100");
             defaultMap.put(FessConfig.THUMBNAIL_HTML_IMAGE_MIN_WIDTH, "100");
             defaultMap.put(FessConfig.THUMBNAIL_HTML_IMAGE_MIN_HEIGHT, "100");
             defaultMap.put(FessConfig.THUMBNAIL_HTML_IMAGE_MIN_HEIGHT, "100");
             defaultMap.put(FessConfig.THUMBNAIL_HTML_IMAGE_MAX_ASPECT_RATIO, "3.0");
             defaultMap.put(FessConfig.THUMBNAIL_HTML_IMAGE_MAX_ASPECT_RATIO, "3.0");

+ 1 - 0
src/main/resources/fess_config.properties

@@ -492,6 +492,7 @@ paging.search.page.start=0
 paging.search.page.size=10
 paging.search.page.size=10
 paging.search.page.max.size=100
 paging.search.page.max.size=100
 
 
+searchlog.agg.shard.size=-1
 
 
 thumbnail.html.image.min.width=100
 thumbnail.html.image.min.width=100
 thumbnail.html.image.min.height=100
 thumbnail.html.image.min.height=100