This commit is contained in:
Shinsuke Sugaya 2018-10-28 17:28:38 +09:00
parent 7b07040da9
commit ab884df75d
7 changed files with 54 additions and 8 deletions

View file

@ -46,10 +46,12 @@ public class SearchLogPager implements Serializable {
public static final String LOG_TYPE_CLICK = "click";
public static final String LOG_TYPE_CLICK_TOP = "click_top_agg";
public static final String LOG_TYPE_CLICK_COUNT = "click_count_agg";
public static final String LOG_TYPE_FAVORITE = "favorite";
public static final String LOG_TYPE_FAVORITE_COUNT = "favorite_count_agg";
public static final int DEFAULT_PAGE_SIZE = 20;
public static final int DEFAULT_CURRENT_PAGE_NUMBER = 1;

View file

@ -95,27 +95,54 @@ public class SearchLogService {
public List<?> getSearchLogList(final SearchLogPager pager) {
final EsPagingResultBean<?> list;
if (SearchLogPager.LOG_TYPE_CLICK.equalsIgnoreCase(pager.logType)
|| SearchLogPager.LOG_TYPE_CLICK_TOP.equalsIgnoreCase(pager.logType)) {
if (SearchLogPager.LOG_TYPE_CLICK.equalsIgnoreCase(pager.logType)) {
list = (EsPagingResultBean<?>) clickLogBhv.selectPage(cb -> {
cb.paging(pager.getPageSize(), pager.getCurrentPageNumber());
cb.query().addOrderBy_RequestedAt_Desc();
createClickLogCondition(pager, cb);
});
} else if (SearchLogPager.LOG_TYPE_CLICK_TOP.equalsIgnoreCase(pager.logType)) {
} else if (SearchLogPager.LOG_TYPE_CLICK_COUNT.equalsIgnoreCase(pager.logType)) {
list = (EsPagingResultBean<?>) clickLogBhv.selectPage(cb -> {
cb.fetchFirst(0);
createClickLogCondition(pager, cb);
cb.aggregation().filter("top_click_filter", null, null, aggs -> {
aggs.setUrl_Count();
});
cb.aggregation().setUrl_Terms(SearchLogPager.LOG_TYPE_CLICK_COUNT, op -> {
op.size(pager.getPageSize());
}, null);
});
final Terms agg = list.getAggregations().get(SearchLogPager.LOG_TYPE_CLICK_COUNT);
final List<? extends Terms.Bucket> buckets = agg.getBuckets();
updatePagerByAgg(pager, buckets.size());
return buckets.stream().map(e -> {
final Map<String, Object> map = new HashMap<>();
map.put(ID, Base64.getUrlEncoder().encodeToString(e.getKeyAsString().getBytes(StandardCharsets.UTF_8)));
map.put(KEY, e.getKeyAsString());
map.put(COUNT, e.getDocCount());
return map;
}).collect(Collectors.toList());
} else if (SearchLogPager.LOG_TYPE_FAVORITE.equalsIgnoreCase(pager.logType)) {
list = (EsPagingResultBean<?>) favoriteLogBhv.selectPage(cb -> {
cb.paging(pager.getPageSize(), pager.getCurrentPageNumber());
cb.query().addOrderBy_CreatedAt_Desc();
createFavoriteLogCondition(pager, cb);
});
} else if (SearchLogPager.LOG_TYPE_FAVORITE_COUNT.equalsIgnoreCase(pager.logType)) {
list = (EsPagingResultBean<?>) favoriteLogBhv.selectPage(cb -> {
cb.fetchFirst(0);
createFavoriteLogCondition(pager, cb);
cb.aggregation().setUrl_Terms(SearchLogPager.LOG_TYPE_FAVORITE_COUNT, op -> {
op.size(pager.getPageSize());
}, null);
});
final Terms agg = list.getAggregations().get(SearchLogPager.LOG_TYPE_FAVORITE_COUNT);
final List<? extends Terms.Bucket> buckets = agg.getBuckets();
updatePagerByAgg(pager, buckets.size());
return buckets.stream().map(e -> {
final Map<String, Object> map = new HashMap<>();
map.put(ID, Base64.getUrlEncoder().encodeToString(e.getKeyAsString().getBytes(StandardCharsets.UTF_8)));
map.put(KEY, e.getKeyAsString());
map.put(COUNT, e.getDocCount());
return map;
}).collect(Collectors.toList());
} else if (SearchLogPager.LOG_TYPE_SEARCH_COUNT_HOUR.equalsIgnoreCase(pager.logType)) {
list = (EsPagingResultBean<?>) searchLogBhv.selectPage(cb -> {
cb.fetchFirst(0);

View file

@ -2862,6 +2862,12 @@ public class FessLabels extends UserMessages {
/** The key of the message: Request Time Avg. by Day */
public static final String LABELS_searchlog_log_type_search_reqtimeavg_day = "{labels.searchlog_log_type_search_reqtimeavg_day}";
/** The key of the message: Click Count */
public static final String LABELS_searchlog_log_type_click_count = "{labels.searchlog_log_type_click_count}";
/** The key of the message: Favorite Count */
public static final String LABELS_searchlog_log_type_favorite_count = "{labels.searchlog_log_type_favorite_count}";
/** The key of the message: Message */
public static final String LABELS_searchlog_log_message = "{labels.searchlog_log_message}";
@ -2889,6 +2895,9 @@ public class FessLabels extends UserMessages {
/** The key of the message: Delete */
public static final String LABELS_searchlog_configuration_button_delete = "{labels.searchlog_configuration_button_delete}";
/** The key of the message: Size */
public static final String LABELS_searchlog_size = "{labels.searchlog_size}";
/** The key of the message: Query ID */
public static final String LABELS_searchlog_queryid = "{labels.searchlog_queryid}";

View file

@ -945,6 +945,8 @@ labels.searchlog_log_type_search_user_hour=User by Hour
labels.searchlog_log_type_search_user_day=User by Day
labels.searchlog_log_type_search_reqtimeavg_hour=Request Time Avg. by Hour
labels.searchlog_log_type_search_reqtimeavg_day=Request Time Avg. by Day
labels.searchlog_log_type_click_count=Click Count
labels.searchlog_log_type_favorite_count=Favorite Count
labels.searchlog_log_message=Message
labels.searchlog_requested_time=Time
labels.searchlog_value=Value

View file

@ -945,6 +945,8 @@ labels.searchlog_log_type_search_user_hour=User by Hour
labels.searchlog_log_type_search_user_day=User by Day
labels.searchlog_log_type_search_reqtimeavg_hour=Request Time Avg. by Hour
labels.searchlog_log_type_search_reqtimeavg_day=Request Time Avg. by Day
labels.searchlog_log_type_click_count=Click Count
labels.searchlog_log_type_favorite_count=Favorite Count
labels.searchlog_log_message=Message
labels.searchlog_requested_time=Time
labels.searchlog_value=Value

View file

@ -945,6 +945,8 @@ labels.searchlog_log_type_search_user_hour=ユーザー数/時
labels.searchlog_log_type_search_user_day=ユーザー数/日
labels.searchlog_log_type_search_reqtimeavg_hour=リクエスト平均時間/時
labels.searchlog_log_type_search_reqtimeavg_day=リクエスト平均時間/日
labels.searchlog_log_type_click_count=クリック数
labels.searchlog_log_type_favorite_count=お気に入り数
labels.searchlog_log_message=メッセージ
labels.searchlog_requested_time=時刻
labels.searchlog_value=

View file

@ -61,6 +61,8 @@
<la:option value="search_reqtimeavg_day_agg"><la:message key="labels.searchlog_log_type_search_reqtimeavg_day" /></la:option>
<la:option value="search_keyword_agg"><la:message key="labels.searchlog_log_type_search_keyword" /></la:option>
<la:option value="search_zerohit_agg"><la:message key="labels.searchlog_log_type_search_zerohit" /></la:option>
<la:option value="click_count_agg"><la:message key="labels.searchlog_log_type_click_count" /></la:option>
<la:option value="favorite_count_agg"><la:message key="labels.searchlog_log_type_favorite_count" /></la:option>
</la:select>
</div>
</div>
@ -156,7 +158,7 @@
<th class="col-sm-3"><la:message
key="labels.searchlog_value" /></th>
</c:if>
<c:if test="${logType.startsWith('search_keyword_') or logType.startsWith('search_zerohit_')}">
<c:if test="${logType.startsWith('search_keyword_') or logType.startsWith('search_zerohit_')} or logType.endsWith('_count_agg')}">
<th><la:message
key="labels.searchlog_value" /></th>
<th class="col-sm-3"><la:message