summaryrefslogtreecommitdiffstats
path: root/container-search/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'container-search/src/main')
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/properties/RankProfileInputProperties.java23
-rw-r--r--container-search/src/main/java/com/yahoo/search/schema/RankProfile.java23
-rw-r--r--container-search/src/main/java/com/yahoo/search/schema/SchemaInfo.java7
-rw-r--r--container-search/src/main/java/com/yahoo/search/schema/SchemaInfoConfigurer.java2
4 files changed, 39 insertions, 16 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/query/properties/RankProfileInputProperties.java b/container-search/src/main/java/com/yahoo/search/query/properties/RankProfileInputProperties.java
index 82e1409c4eb..ea2120dae3f 100644
--- a/container-search/src/main/java/com/yahoo/search/query/properties/RankProfileInputProperties.java
+++ b/container-search/src/main/java/com/yahoo/search/query/properties/RankProfileInputProperties.java
@@ -6,6 +6,8 @@ import com.yahoo.language.process.Embedder;
import com.yahoo.processing.IllegalInputException;
import com.yahoo.processing.request.CompoundName;
import com.yahoo.search.Query;
+import com.yahoo.search.schema.RankProfile;
+import com.yahoo.search.schema.RankProfile.InputType;
import com.yahoo.search.schema.SchemaInfo;
import com.yahoo.search.schema.internal.TensorConverter;
import com.yahoo.search.query.Properties;
@@ -39,9 +41,16 @@ public class RankProfileInputProperties extends Properties {
public void set(CompoundName name, Object value, Map<String, String> context) {
if (RankFeatures.isFeatureName(name.toString())) {
try {
- TensorType expectedType = typeOf(name);
- if (expectedType != null) {
- value = tensorConverter.convertTo(expectedType,
+ var expectedType = typeOf(name);
+ System.err.println("setting rank feature '" + name + "' -> " + value + " :: " + value.getClass());
+ if (expectedType != null && expectedType.declaredString()) {
+ System.err.println("expected type: declared string");
+ var e = new IllegalArgumentException("foo");
+ e.fillInStackTrace();
+ e.printStackTrace();
+ }
+ if (expectedType != null && ! expectedType.declaredString()) {
+ value = tensorConverter.convertTo(expectedType.tensorType(),
name.last(),
value,
query.getModel().getLanguage(),
@@ -59,14 +68,14 @@ public class RankProfileInputProperties extends Properties {
@Override
public void requireSettable(CompoundName name, Object value, Map<String, String> context) {
if (RankFeatures.isFeatureName(name.toString())) {
- TensorType expectedType = typeOf(name);
- if (expectedType != null)
- verifyType(name, value, expectedType);
+ var expectedType = typeOf(name);
+ if (expectedType != null && ! expectedType.declaredString())
+ verifyType(name, value, expectedType.tensorType());
}
super.requireSettable(name, value, context);
}
- private TensorType typeOf(CompoundName name) {
+ private RankProfile.InputType typeOf(CompoundName name) {
// Session is lazily resolved because order matters:
// model.sources+restrict must be set in the query before this is done
if (session == null)
diff --git a/container-search/src/main/java/com/yahoo/search/schema/RankProfile.java b/container-search/src/main/java/com/yahoo/search/schema/RankProfile.java
index d681062451c..a5b8d328a7a 100644
--- a/container-search/src/main/java/com/yahoo/search/schema/RankProfile.java
+++ b/container-search/src/main/java/com/yahoo/search/schema/RankProfile.java
@@ -18,10 +18,25 @@ import java.util.Objects;
@Beta
public class RankProfile {
+ public record InputType(TensorType tensorType, boolean declaredString) {
+ public String toString() {
+ return declaredString ? "string" : tensorType.toString();
+ }
+ public static InputType fromSpec(String spec) {
+ if ("string".equals(spec)) {
+ return new InputType(TensorType.empty, true);
+ }
+ if ("double".equals(spec)) {
+ return new InputType(TensorType.empty, false);
+ }
+ return new InputType(TensorType.fromSpec(spec), false);
+ }
+ }
+
private final String name;
private final boolean hasSummaryFeatures;
private final boolean hasRankFeatures;
- private final Map<String, TensorType> inputs;
+ private final Map<String, InputType> inputs;
// Assigned when this is added to a schema
private Schema schema = null;
@@ -52,7 +67,7 @@ public class RankProfile {
public boolean hasRankFeatures() { return hasRankFeatures; }
/** Returns the inputs explicitly declared in this rank profile. */
- public Map<String, TensorType> inputs() { return inputs; }
+ public Map<String, InputType> inputs() { return inputs; }
@Override
public boolean equals(Object o) {
@@ -80,7 +95,7 @@ public class RankProfile {
private final String name;
private boolean hasSummaryFeatures = true;
private boolean hasRankFeatures = true;
- private final Map<String, TensorType> inputs = new LinkedHashMap<>();
+ private final Map<String, InputType> inputs = new LinkedHashMap<>();
public Builder(String name) {
this.name = Objects.requireNonNull(name);
@@ -96,7 +111,7 @@ public class RankProfile {
return this;
}
- public Builder addInput(String name, TensorType type) {
+ public Builder addInput(String name, InputType type) {
inputs.put(name, type);
return this;
}
diff --git a/container-search/src/main/java/com/yahoo/search/schema/SchemaInfo.java b/container-search/src/main/java/com/yahoo/search/schema/SchemaInfo.java
index 263fa4058c7..df7a5cab3c1 100644
--- a/container-search/src/main/java/com/yahoo/search/schema/SchemaInfo.java
+++ b/container-search/src/main/java/com/yahoo/search/schema/SchemaInfo.java
@@ -6,7 +6,6 @@ import com.yahoo.component.annotation.Inject;
import com.yahoo.container.QrSearchersConfig;
import com.yahoo.search.Query;
import com.yahoo.search.config.SchemaInfoConfig;
-import com.yahoo.tensor.TensorType;
import java.util.Collection;
import java.util.Collections;
@@ -184,16 +183,16 @@ public class SchemaInfo {
* feature is declared in this rank profile in multiple schemas
* of this session with conflicting types
*/
- public TensorType rankProfileInput(String rankFeature, String rankProfile) {
+ public RankProfile.InputType rankProfileInput(String rankFeature, String rankProfile) {
if (schemas.isEmpty()) return null; // no matching schemas - validated elsewhere
List<RankProfile> profiles = profilesNamed(rankProfile);
if (profiles.isEmpty())
throw new IllegalArgumentException("No profile named '" + rankProfile + "' exists in schemas [" +
schemas.stream().map(Schema::name).collect(Collectors.joining(", ")) + "]");
- TensorType foundType = null;
+ RankProfile.InputType foundType = null;
RankProfile declaringProfile = null;
for (RankProfile profile : profiles) {
- TensorType newlyFoundType = profile.inputs().get(rankFeature);
+ RankProfile.InputType newlyFoundType = profile.inputs().get(rankFeature);
if (newlyFoundType == null) continue;
if (foundType != null && ! newlyFoundType.equals(foundType))
throw new IllegalArgumentException("Conflicting input type declarations for '" + rankFeature + "': " +
diff --git a/container-search/src/main/java/com/yahoo/search/schema/SchemaInfoConfigurer.java b/container-search/src/main/java/com/yahoo/search/schema/SchemaInfoConfigurer.java
index b70f5145e56..b576260b85d 100644
--- a/container-search/src/main/java/com/yahoo/search/schema/SchemaInfoConfigurer.java
+++ b/container-search/src/main/java/com/yahoo/search/schema/SchemaInfoConfigurer.java
@@ -27,7 +27,7 @@ class SchemaInfoConfigurer {
profileBuilder.setHasSummaryFeatures(profileConfig.hasSummaryFeatures());
profileBuilder.setHasRankFeatures(profileConfig.hasRankFeatures());
for (var inputConfig : profileConfig.input())
- profileBuilder.addInput(inputConfig.name(), TensorType.fromSpec(inputConfig.type()));
+ profileBuilder.addInput(inputConfig.name(), RankProfile.InputType.fromSpec(inputConfig.type()));
builder.add(profileBuilder.build());
}