summaryrefslogtreecommitdiffstats
path: root/config-model/src/main
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-09-07 22:38:11 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2021-09-07 22:38:11 +0200
commit3eda134d8483a450ddfc8aa7314f45f1fa8fabfe (patch)
tree9d1b4aa08e41c3f997e2344d78c77b4da2900659 /config-model/src/main
parent994d45c9d86d9781db5e93d8fc0a649ae12bd42b (diff)
If you seemingly inherit yourself, just assume that you try to inherit the same named rankprofile in the base document type.
Diffstat (limited to 'config-model/src/main')
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java20
1 files changed, 17 insertions, 3 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 17b5953b824..97770b6ebb9 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java
@@ -9,6 +9,7 @@ import com.yahoo.search.query.profile.types.QueryProfileType;
import com.yahoo.search.query.ranking.Diversity;
import com.yahoo.searchdefinition.document.Attribute;
import com.yahoo.searchdefinition.document.ImmutableSDField;
+import com.yahoo.searchdefinition.document.SDDocumentType;
import com.yahoo.searchdefinition.expressiontransforms.ExpressionTransforms;
import com.yahoo.searchdefinition.expressiontransforms.RankProfileTransformContext;
import com.yahoo.searchdefinition.parser.ParseException;
@@ -240,12 +241,25 @@ public class RankProfile implements Cloneable {
}
}
+ private RankProfile resolveInherited(ImmutableSearch search) {
+ SDDocumentType documentType = search.getDocument();
+ if (documentType != null) {
+ if (name.equals(inheritedName)) {
+ // If you seemingly inherit yourself, you are actually referencing a rank-profile in one of your inherited schemas
+ for (SDDocumentType baseType : documentType.getInheritedTypes()) {
+ RankProfile resolvedFromBase = rankProfileRegistry.resolve(baseType, inheritedName);
+ if (resolvedFromBase != null) return resolvedFromBase;
+ }
+ }
+ return rankProfileRegistry.resolve(documentType, inheritedName);
+ }
+ return rankProfileRegistry.get(search.getName(), inheritedName);
+ }
+
private RankProfile resolveInherited() {
if (inheritedName == null) return null;
return (getSearch() != null)
- ? ((search.getDocument() != null)
- ? rankProfileRegistry.resolve(search.getDocument(), inheritedName)
- : rankProfileRegistry.get(search.getName(), inheritedName))
+ ? resolveInherited(search)
: rankProfileRegistry.getGlobal(inheritedName);
}