ignore search log of the same sessionId when registering suggest word
@@ -107,6 +107,7 @@ public class SuggestHelper {
}
public void indexFromSearchLog(final List<SearchLog> searchLogList) {
+ final Set<String> sessionIdSet = new HashSet<>();
searchLogList.stream().forEach(
searchLog -> {
if (searchLog.getHitCount() == null
@@ -114,6 +115,11 @@ public class SuggestHelper {
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<>();
@@ -140,6 +146,7 @@ public class SuggestHelper {
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);
}
}
});
