summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2023-06-09 14:03:03 +0200
committerTor Egge <Tor.Egge@online.no>2023-06-09 14:03:03 +0200
commit73bb057b102e6bb2c991f8050a98f4ea748e45c3 (patch)
treec02f6819ef4fadc34b08c2552e60e5c17bcdcc3d /config-model
parent360ca4fbfc34322c9ff4add8921f3d130e266f48 (diff)
Print warning when trying to enable hnsw index in streaming mode.
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/application/validation/StreamingValidator.java12
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/StreamingValidatorTest.java38
2 files changed, 49 insertions, 1 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/StreamingValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/StreamingValidator.java
index ad126cfa22b..6008536db0b 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/StreamingValidator.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/StreamingValidator.java
@@ -65,7 +65,17 @@ public class StreamingValidator extends Validator {
// attribute indexing ourselves (IntegerIndex2Attribute)
if (sd.getDataType() instanceof NumericDataType) return;
// Tensor fields are only searchable via nearest neighbor search, and match semantics are irrelevant.
- if (sd.getDataType() instanceof TensorDataType) return;
+ if (sd.getDataType() instanceof TensorDataType) {
+ for (var fieldAttribute : sd.getAttributes().values()) {
+ if (fieldAttribute.hnswIndexParams().isPresent()) {
+ logger.logApplicationPackage(Level.WARNING,
+ "For streaming search cluster '" + sc.getClusterName() +
+ "', SD field '" + sd.getName() +
+ "': hnsw index is not relevant and not supported, ignoring setting");
+ }
+ }
+ return;
+ }
logger.logApplicationPackage(Level.WARNING, "For streaming search cluster '" + sc.getClusterName() +
"', SD field '" + sd.getName() +
"': 'attribute' has same match semantics as 'index'.");
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/StreamingValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/StreamingValidatorTest.java
index fd1e6be27fd..82bd96d32d7 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/StreamingValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/StreamingValidatorTest.java
@@ -1,9 +1,20 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.application.validation;
+import com.yahoo.config.application.api.DeployLogger;
+import com.yahoo.config.model.deploy.DeployState;
+import com.yahoo.schema.derived.TestableDeployLogger;
+import com.yahoo.vespa.model.VespaModel;
+import com.yahoo.vespa.model.content.utils.ApplicationPackageBuilder;
+import com.yahoo.vespa.model.content.utils.ContentClusterBuilder;
+import com.yahoo.vespa.model.content.utils.DocType;
+import com.yahoo.vespa.model.content.utils.SchemaBuilder;
import com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg;
import org.junit.jupiter.api.Test;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -21,4 +32,31 @@ public class StreamingValidatorTest {
assertTrue(exception.getMessage().contains("For streaming search cluster 'content.ad': Attribute 'campaign_ref' has type 'Reference<campaign>'. " +
"Document references and imported fields are not allowed in streaming search."));
}
+
+ @Test
+ void tensor_field_without_index_gives_no_warning() {
+ var logger = new TestableDeployLogger();
+ var model = createModel(logger, "field nn type tensor(x[2]) { indexing: attribute | summary\n" +
+ "attribute { distance-metric: euclidean } }");
+ assertTrue(logger.warnings.isEmpty());
+ }
+
+ @Test
+ void tensor_field_with_index_triggers_warning_in_streaming_search() {
+ var logger = new TestableDeployLogger();
+ var model = createModel(logger, "field nn type tensor(x[2]) { indexing: attribute | index | summary\n" +
+ "attribute { distance-metric: euclidean } }");
+ assertEquals(1, logger.warnings.size());
+ assertEquals("For streaming search cluster 'content.test', SD field 'nn': hnsw index is not relevant and not supported, ignoring setting",
+ logger.warnings.get(0));
+ }
+
+ private static VespaModel createModel(DeployLogger logger, String sdContent) {
+ var builder = new DeployState.Builder();
+ builder.deployLogger(logger);
+ return new ApplicationPackageBuilder()
+ .addCluster(new ContentClusterBuilder().name("content").docTypes(List.of(DocType.streaming("test"))))
+ .addSchemas(new SchemaBuilder().name("test").content(sdContent).build())
+ .buildCreator().create(builder);
+ }
}