summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java26
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/RankProfileTypeSettingsProcessor.java2
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java1
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/types/FieldType.java7
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/types/TensorFieldType.java3
5 files changed, 25 insertions, 14 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 18deab70f3e..2f28d9adb8b 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.QueryProfile;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.search.query.profile.config.QueryProfileXMLReader;
import com.yahoo.search.query.profile.types.FieldDescription;
+import com.yahoo.search.query.profile.types.QueryProfileType;
import com.yahoo.search.query.profile.types.TensorFieldType;
import com.yahoo.search.query.ranking.Diversity;
import com.yahoo.searchdefinition.document.SDField;
@@ -758,18 +759,19 @@ public class RankProfile implements Serializable, Cloneable {
}
// Add query features from rank profile types reached from the "default" profile
- QueryProfile profile = queryProfiles.getComponent("default");
- if (profile != null && profile.getType() != null) {
- profile.listTypes(CompoundName.empty, Collections.emptyMap()).forEach((prefix, queryProfileType) -> {
- for (FieldDescription field : queryProfileType.declaredFields().values()) {
- TensorType type = TensorType.empty; // assume the empty (aka double) type by default
- if (field.getType() instanceof TensorFieldType)
- type = ((TensorFieldType)field.getType()).type();
-
- String feature = FeatureNames.asQueryFeature(prefix.append(field.getName()).toString());
- context.setType(feature, type);
- }
- });
+ for (QueryProfileType queryProfileType : queryProfiles.getTypeRegistry().allComponents()) {
+ for (FieldDescription field : queryProfileType.declaredFields().values()) {
+ TensorType type = field.getType().asTensorType();
+ String feature = FeatureNames.asQueryFeature(field.getName());
+ TensorType existingType = context.getType(feature);
+ if (existingType != null)
+ type = existingType.dimensionwiseGeneralizationWith(type).orElseThrow( () ->
+ new IllegalArgumentException(queryProfileType + " contains query feature " + feature +
+ " with type " + field.getType().asTensorType() +
+ ", but this is already defined " +
+ "in another query profile with type " + context.getType(feature)));
+ context.setType(feature, type);
+ }
}
return context;
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/RankProfileTypeSettingsProcessor.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/RankProfileTypeSettingsProcessor.java
index c121cdfdd9a..7cb9fee3449 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/RankProfileTypeSettingsProcessor.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/RankProfileTypeSettingsProcessor.java
@@ -84,7 +84,7 @@ public class RankProfileTypeSettingsProcessor extends Processor {
if (fieldType instanceof TensorFieldType) {
TensorFieldType tensorFieldType = (TensorFieldType)fieldType;
FeatureNames.argumentOf(fieldName).ifPresent(argument ->
- addQueryFeatureTypeToRankProfiles(argument, tensorFieldType.type().toString()));
+ addQueryFeatureTypeToRankProfiles(argument, tensorFieldType.asTensorType().toString()));
}
}
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java b/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java
index 6be0dac6448..e8d8ecb02bb 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java
@@ -4,6 +4,7 @@ package com.yahoo.search.query.profile.types;
import com.google.common.collect.ImmutableList;
import com.yahoo.processing.request.CompoundName;
import com.yahoo.search.query.profile.QueryProfile;
+import com.yahoo.tensor.TensorType;
import java.util.Arrays;
import java.util.Collections;
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldType.java b/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldType.java
index 69c07843681..3bfd33668e6 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldType.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldType.java
@@ -6,6 +6,7 @@ import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry;
import com.yahoo.search.yql.YqlQuery;
import com.yahoo.tensor.Tensor;
+import com.yahoo.tensor.TensorType;
/**
* Superclass of query type field types.
@@ -43,6 +44,12 @@ public abstract class FieldType {
public abstract Object convertFrom(Object o, CompiledQueryProfileRegistry registry);
/**
+ * Returns this type as a tensor type: The true tensor type is this is a tensor field an an empty type -
+ * interpreted as a double in numerical contexts - otherwise
+ */
+ public TensorType asTensorType() { return TensorType.empty; }
+
+ /**
* Returns the field type for a given string name.
*
* @param typeString a type string - a primitive name, "query-profile" or "query-profile:profile-name"
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/types/TensorFieldType.java b/container-search/src/main/java/com/yahoo/search/query/profile/types/TensorFieldType.java
index 53ab7aefafd..9699a72cb31 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/types/TensorFieldType.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/types/TensorFieldType.java
@@ -21,7 +21,8 @@ public class TensorFieldType extends FieldType {
}
/** Returns information about the type of tensor this will hold */
- public TensorType type() { return type; }
+ @Override
+ public TensorType asTensorType() { return type; }
@Override
public Class getValueClass() { return Tensor.class; }