diff options
author | Jon Bratseth <bratseth@gmail.com> | 2020-06-02 08:44:21 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2020-06-02 08:44:21 +0200 |
commit | ac03f1b821c15062986c6542d248b19c66a17db9 (patch) | |
tree | d22523a69073f8d747ac09b614cd88f0ec117106 /config-model/src/main/java/com | |
parent | 2e3d463d90a4834b65446415e1f92389091716ab (diff) |
Explicitly inherit summary features
Diffstat (limited to 'config-model/src/main/java/com')
-rw-r--r-- | config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java index ea126123a25..8b2a190feb9 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java @@ -91,6 +91,7 @@ public class RankProfile implements Cloneable { private double rankScoreDropLimit = -Double.MAX_VALUE; private Set<ReferenceNode> summaryFeatures; + private String inheritedSummaryFeatures; private Set<ReferenceNode> rankFeatures; @@ -386,9 +387,15 @@ public class RankProfile implements Cloneable { /** Returns a read-only view of the summary features to use in this profile. This is never null */ public Set<ReferenceNode> getSummaryFeatures() { + if (inheritedSummaryFeatures != null && summaryFeatures != null) { + Set<ReferenceNode> combined = new HashSet<>(); + combined.addAll(getInherited().getSummaryFeatures()); + combined.addAll(summaryFeatures); + return Collections.unmodifiableSet(combined); + } if (summaryFeatures != null) return Collections.unmodifiableSet(summaryFeatures); if (getInherited() != null) return getInherited().getSummaryFeatures(); - return Collections.emptySet(); + return Set.of(); } private void addSummaryFeature(ReferenceNode feature) { @@ -397,17 +404,30 @@ public class RankProfile implements Cloneable { summaryFeatures.add(feature); } - /** - * Adds the content of the given feature list to the internal list of summary features. - * - * @param features The features to add. - */ + /** Adds the content of the given feature list to the internal list of summary features. */ public void addSummaryFeatures(FeatureList features) { for (ReferenceNode feature : features) { addSummaryFeature(feature); } } + /** + * Sets the name this should inherit the summary features of. + * Without setting this, this will either have the summary features of the parent, + * or if summary features are set in this, only have the summary features in this. + * With this set the resulting summary features of this will be the superset of those defined in this and + * the final (with inheritance included) summary features of the given parent. + * The profile must be the profile which is directly inherited by this. + * + * @param parentProfile + */ + public void setInheritedSummaryFeatures(String parentProfile) { + if ( ! parentProfile.equals(inheritedName)) + throw new IllegalArgumentException("This can only inherit the summary features of its parent, '" + + inheritedName + ", but attemtping to inherit '" + parentProfile); + this.inheritedSummaryFeatures = parentProfile; + } + /** Returns a read-only view of the rank features to use in this profile. This is never null */ public Set<ReferenceNode> getRankFeatures() { if (rankFeatures != null) return Collections.unmodifiableSet(rankFeatures); |