diff options
author | Jon Bratseth <bratseth@oath.com> | 2018-02-05 13:20:28 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@oath.com> | 2018-02-05 13:20:28 +0100 |
commit | ff42200912e298bb8d4f29da8d18c8b0079b04b7 (patch) | |
tree | 12fb6fd3f49489b462eaa94244be9c3d9a956755 /config-model/src | |
parent | 595d685af6fe641cf735278925f73a570e441ab5 (diff) |
Use all query profiles and handle conflicts
Diffstat (limited to 'config-model/src')
2 files changed, 15 insertions, 13 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())); } } |