From 7cc8b0fed52463dd950e16209d79e45a62dfaf37 Mon Sep 17 00:00:00 2001 From: Viktor Lofgren Date: Sun, 11 Feb 2024 19:58:55 +0100 Subject: [PATCH] (search) Experimental support for clustering search results Improves clustering of results. --- .../marginalia/search/SearchResultClusterer.java | 2 -- .../search/model/ClusteredUrlDetails.java | 15 --------------- 2 files changed, 17 deletions(-) diff --git a/code/services-application/search-service/src/main/java/nu/marginalia/search/SearchResultClusterer.java b/code/services-application/search-service/src/main/java/nu/marginalia/search/SearchResultClusterer.java index a2869879..e5b61788 100644 --- a/code/services-application/search-service/src/main/java/nu/marginalia/search/SearchResultClusterer.java +++ b/code/services-application/search-service/src/main/java/nu/marginalia/search/SearchResultClusterer.java @@ -1,7 +1,6 @@ package nu.marginalia.search; import nu.marginalia.query.model.QueryResponse; -import nu.marginalia.search.command.SearchParameters; import nu.marginalia.search.model.ClusteredUrlDetails; import nu.marginalia.search.model.UrlDetails; @@ -46,7 +45,6 @@ public class SearchResultClusterer { ) .values().stream() .map(ClusteredUrlDetails::new) - .mapMulti(ClusteredUrlDetails::splitSmallClusters) // split small clusters into singletons .sorted() .limit(total) .toList(); diff --git a/code/services-application/search-service/src/main/java/nu/marginalia/search/model/ClusteredUrlDetails.java b/code/services-application/search-service/src/main/java/nu/marginalia/search/model/ClusteredUrlDetails.java index 0f9bbfaf..6dd7390d 100644 --- a/code/services-application/search-service/src/main/java/nu/marginalia/search/model/ClusteredUrlDetails.java +++ b/code/services-application/search-service/src/main/java/nu/marginalia/search/model/ClusteredUrlDetails.java @@ -6,7 +6,6 @@ import nu.marginalia.model.idx.WordFlags; import org.jetbrains.annotations.NotNull; import java.util.*; -import java.util.function.Consumer; import java.util.stream.Collectors; /** A class to hold a list of UrlDetails, grouped by domain, where the first one is the main result @@ -72,20 +71,6 @@ public class ClusteredUrlDetails implements Comparable { @Getter public final List rest; - public void splitSmallClusters(Consumer consumer) { - if (rest.isEmpty()) - consumer.accept(this); - else if (rest.size() < 2) { // Only one additional result - consumer.accept(new ClusteredUrlDetails(first)); - rest.stream() - .map(ClusteredUrlDetails::new) - .forEach(consumer); - } - else { - consumer.accept(this); - } - } - public EdgeDomain getDomain() { return first.url.getDomain(); }