use of org.codelibs.fess.es.log.exentity.SearchFieldLog in project fess by codelibs.
the class SearchLogHelper method storeSearchLogList.
private void storeSearchLogList(final List<SearchLog> searchLogList) {
final SearchLogBhv searchLogBhv = ComponentUtil.getComponent(SearchLogBhv.class);
final SearchFieldLogBhv searchFieldLogBhv = ComponentUtil.getComponent(SearchFieldLogBhv.class);
searchLogBhv.batchUpdate(searchLogList, op -> {
op.setRefreshPolicy(Constants.TRUE);
});
searchLogList.stream().forEach(searchLog -> {
final List<SearchFieldLog> fieldLogList = new ArrayList<>();
searchLog.getSearchFieldLogList().stream().forEach(fieldLog -> {
fieldLog.setSearchLogId(searchLog.getId());
fieldLogList.add(fieldLog);
});
searchFieldLogBhv.batchInsert(fieldLogList);
});
}
use of org.codelibs.fess.es.log.exentity.SearchFieldLog in project fess by codelibs.
the class SuggestHelper method indexFromSearchLog.
public void indexFromSearchLog(final List<SearchLog> searchLogList) {
final Set<String> sessionIdSet = new HashSet<>();
searchLogList.stream().forEach(searchLog -> {
if (searchLog.getHitCount() == null || searchLog.getHitCount().longValue() < fessConfig.getSuggestMinHitCountAsInteger().longValue()) {
return;
}
final String sessionId = searchLog.getUserSessionId();
if (sessionId == null || sessionIdSet.contains(sessionId)) {
return;
}
final StringBuilder sb = new StringBuilder(100);
final List<String> fields = new ArrayList<>();
final List<String> tags = new ArrayList<>();
final List<String> roles = new ArrayList<>();
for (final SearchFieldLog searchFieldLog : searchLog.getSearchFieldLogList()) {
final String name = searchFieldLog.getName();
if (contentFieldNameSet.contains(name)) {
if (sb.length() > 0) {
sb.append(TEXT_SEP);
}
sb.append(searchFieldLog.getValue());
fields.add(name);
} else if (tagFieldNameSet.contains(name)) {
tags.add(searchFieldLog.getValue());
} else if (roleFieldNameSet.contains(name)) {
roles.add(searchFieldLog.getValue());
}
}
if (sb.length() > 0) {
final String[] langs = searchLog.getLanguages() == null ? new String[] {} : searchLog.getLanguages().split(",");
stream(searchLog.getRoles()).of(stream -> stream.forEach(role -> roles.add(role)));
if (fessConfig.isValidSearchLogPermissions(roles.toArray(new String[roles.size()]))) {
suggester.indexer().indexFromSearchWord(sb.toString(), fields.toArray(new String[fields.size()]), tags.toArray(new String[tags.size()]), roles.toArray(new String[roles.size()]), 1, langs);
sessionIdSet.add(sessionId);
}
}
});
suggester.refresh();
}
Aggregations