diff options
author | Arne Juul <arnej@yahooinc.com> | 2023-05-11 11:31:14 +0000 |
---|---|---|
committer | Arne Juul <arnej@yahooinc.com> | 2023-05-11 12:34:35 +0000 |
commit | 47b370c90715a15939474951fbdb6fad987073e9 (patch) | |
tree | 1b8fc8756d2e9b5c9c38b7ee4ca8c82a3cd25e28 /config-model/src/main | |
parent | 5693b9621d9882f0e9a66c7d6441b898cb43f6d9 (diff) |
add filtering to hide implicitly added match features
Diffstat (limited to 'config-model/src/main')
-rw-r--r-- | config-model/src/main/java/com/yahoo/schema/RankProfile.java | 28 | ||||
-rw-r--r-- | config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java | 5 |
2 files changed, 31 insertions, 2 deletions
diff --git a/config-model/src/main/java/com/yahoo/schema/RankProfile.java b/config-model/src/main/java/com/yahoo/schema/RankProfile.java index 639930041c3..69f32daef4a 100644 --- a/config-model/src/main/java/com/yahoo/schema/RankProfile.java +++ b/config-model/src/main/java/com/yahoo/schema/RankProfile.java @@ -108,6 +108,7 @@ public class RankProfile implements Cloneable { private String inheritedSummaryFeaturesProfileName; private Set<ReferenceNode> matchFeatures; + private Set<String> hiddenMatchFeatures; private String inheritedMatchFeaturesProfileName; private Set<ReferenceNode> rankFeatures; @@ -605,6 +606,12 @@ public class RankProfile implements Cloneable { .orElse(Set.of()); } + public Set<String> getHiddenMatchFeatures() { + if (hiddenMatchFeatures != null) return Collections.unmodifiableSet(hiddenMatchFeatures); + return uniquelyInherited(p -> p.getHiddenMatchFeatures(), f -> ! f.isEmpty(), "hidden match features") + .orElse(Set.of()); + } + private void addSummaryFeature(ReferenceNode feature) { if (summaryFeatures == null) summaryFeatures = new LinkedHashSet<>(); @@ -617,6 +624,21 @@ public class RankProfile implements Cloneable { matchFeatures.add(feature); } + private void addImplicitMatchFeatures(List<FeatureList> list) { + if (matchFeatures == null) + matchFeatures = new LinkedHashSet<>(); + if (hiddenMatchFeatures == null) + hiddenMatchFeatures = new LinkedHashSet<>(); + for (var features : list) { + for (ReferenceNode feature : features) { + if (! matchFeatures.contains(feature)) { + matchFeatures.add(feature); + hiddenMatchFeatures.add(feature.toString()); + } + } + } + } + /** Adds the content of the given feature list to the internal list of summary features. */ public void addSummaryFeatures(FeatureList features) { for (ReferenceNode feature : features) { @@ -1037,16 +1059,18 @@ public class RankProfile implements Cloneable { var needInputs = new HashSet<String>(); var recorder = new InputRecorder(needInputs); recorder.process(globalPhaseRanking.function().getBody(), context); + List<FeatureList> addIfMissing = new ArrayList<>(); for (String input : needInputs) { if (input.startsWith("constant(") || input.startsWith("query(")) { continue; } try { - addMatchFeatures(new FeatureList(input)); + addIfMissing.add(new FeatureList(input)); } catch (com.yahoo.searchlib.rankingexpression.parser.ParseException e) { throw new IllegalArgumentException("invalid input in global-phase expression: "+input); } } + addImplicitMatchFeatures(addIfMissing); } } @@ -1132,7 +1156,7 @@ public class RankProfile implements Cloneable { allImportedFields().forEach(field -> addAttributeFeatureTypes(field, featureTypes)); return featureTypes; } - + public MapEvaluationTypeContext typeContext(QueryProfileRegistry queryProfiles, Map<Reference, TensorType> featureTypes) { MapEvaluationTypeContext context = new MapEvaluationTypeContext(getExpressionFunctions(), featureTypes); diff --git a/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java b/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java index 6272563f833..349fe1404ed 100644 --- a/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java +++ b/config-model/src/main/java/com/yahoo/schema/derived/RawRankProfile.java @@ -133,6 +133,7 @@ public class RawRankProfile implements RankProfilesConfig.Producer { private final Map<String, FieldRankSettings> fieldRankSettings = new java.util.LinkedHashMap<>(); private final Set<ReferenceNode> summaryFeatures; private final Set<ReferenceNode> matchFeatures; + private final Collection<String> hiddenMatchFeatures; private final Set<ReferenceNode> rankFeatures; private final Map<String, String> featureRenames = new java.util.LinkedHashMap<>(); private final List<RankProfile.RankProperty> rankProperties; @@ -183,6 +184,7 @@ public class RawRankProfile implements RankProfilesConfig.Producer { globalPhaseRanking = compiled.getGlobalPhaseRanking(); summaryFeatures = new LinkedHashSet<>(compiled.getSummaryFeatures()); matchFeatures = new LinkedHashSet<>(compiled.getMatchFeatures()); + hiddenMatchFeatures = compiled.getHiddenMatchFeatures(); rankFeatures = compiled.getRankFeatures(); rerankCount = compiled.getRerankCount(); globalPhaseRerankCount = compiled.getGlobalPhaseRerankCount(); @@ -394,6 +396,9 @@ public class RawRankProfile implements RankProfilesConfig.Producer { for (ReferenceNode feature : matchFeatures) { properties.add(new Pair<>("vespa.match.feature", feature.toString())); } + for (String feature : hiddenMatchFeatures) { + properties.add(new Pair<>("vespa.hidden.matchfeature", feature)); + } for (ReferenceNode feature : rankFeatures) { properties.add(new Pair<>("vespa.dump.feature", feature.toString())); } |