(search) Experimental support for clustering search results
Improves clustering of results.
This commit is contained in:
parent
a77846373b
commit
7cc8b0fed5
@ -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();
|
||||
|
@ -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<ClusteredUrlDetails> {
|
||||
@Getter
|
||||
public final List<UrlDetails> rest;
|
||||
|
||||
public void splitSmallClusters(Consumer<ClusteredUrlDetails> 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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user