summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config-model/src/test/derived/neuralnet/query-profiles.cfg1
-rw-r--r--config-model/src/test/derived/neuralnet/query-profiles/types/DefaultQueryProfileType.xml2
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java16
3 files changed, 11 insertions, 8 deletions
diff --git a/config-model/src/test/derived/neuralnet/query-profiles.cfg b/config-model/src/test/derived/neuralnet/query-profiles.cfg
index ed69df7895d..817640a89fd 100644
--- a/config-model/src/test/derived/neuralnet/query-profiles.cfg
+++ b/config-model/src/test/derived/neuralnet/query-profiles.cfg
@@ -3,6 +3,7 @@ queryprofile[].type "DefaultQueryProfileType"
queryprofiletype[].id "DefaultQueryProfileType"
queryprofiletype[].strict false
queryprofiletype[].matchaspath false
+queryprofiletype[].inherit[] "native"
queryprofiletype[].field[].name "ranking"
queryprofiletype[].field[].type "query-profile:ranking_0_0"
queryprofiletype[].field[].overridable true
diff --git a/config-model/src/test/derived/neuralnet/query-profiles/types/DefaultQueryProfileType.xml b/config-model/src/test/derived/neuralnet/query-profiles/types/DefaultQueryProfileType.xml
index e74152638fb..42336098a9a 100644
--- a/config-model/src/test/derived/neuralnet/query-profiles/types/DefaultQueryProfileType.xml
+++ b/config-model/src/test/derived/neuralnet/query-profiles/types/DefaultQueryProfileType.xml
@@ -1,5 +1,5 @@
<!-- Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
-<query-profile-type id="DefaultQueryProfileType">
+<query-profile-type id="DefaultQueryProfileType" inherits="native">
<field name="ranking.features.query(W_0)" type="tensor(x[9],hidden[9])" />
<field name="ranking.features.query(b_0)" type="tensor(hidden[9])" />
<field name="ranking.features.query(W_1)" type="tensor(hidden[9],out[9])" />
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java b/container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java
index e3696916c53..d6faa6097f9 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/types/QueryProfileType.java
@@ -24,9 +24,8 @@ import static com.yahoo.text.Lowercase.toLowerCase;
*/
public class QueryProfileType extends FreezableSimpleComponent {
- private static final String simpleClassName = QueryProfileType.class.getSimpleName();
-
private final CompoundName componentIdAsCompoundName;
+
/** The fields of this query profile type */
private Map<String, FieldDescription> fields;
@@ -307,6 +306,7 @@ public class QueryProfileType extends FreezableSimpleComponent {
private QueryProfileType extendOrCreateQueryProfileType(String name, QueryProfileTypeRegistry registry) {
QueryProfileType type = null;
FieldDescription fieldDescription = getField(name);
+ System.out.println("Extending/creating " + name + ". Description: " + fieldDescription + " (is frozen " + isFrozen() + ")");
if (fieldDescription != null) {
if ( ! (fieldDescription.getType() instanceof QueryProfileFieldType))
throw new IllegalArgumentException("Cannot use name '" + name + "' as a prefix because it is " +
@@ -317,11 +317,13 @@ public class QueryProfileType extends FreezableSimpleComponent {
if (type == null) {
type = registry.getComponent(name);
- if (type != null) { // found in registry but not already added in this type: extend it
- type = new QueryProfileType(ComponentId.createAnonymousComponentId(type.getIdString()),
- new HashMap<>(),
- List.of(type));
- }
+ }
+
+ // found in registry but not already added in *this* type (getField also checks parents): extend it
+ if (type != null && ! fields.containsKey(name)) {
+ type = new QueryProfileType(ComponentId.createAnonymousComponentId(type.getIdString()),
+ new HashMap<>(),
+ List.of(type));
}
if (type == null) { // create it