summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2024-01-06 20:45:12 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2024-01-06 20:45:12 +0100
commit64bd1394e806bb5857c872468282c7b4023b33ce (patch)
tree579ab917edb393529016f39073f4992d7bb53e50
parent5fb35b0e41b0f62d9b66fd9c4fcee23f82a8400f (diff)
Add testcase normalize during query processing.
-rw-r--r--config-model/src/test/java/com/yahoo/schema/derived/IndexInfoTestCase.java55
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/utils/SchemaBuilder.java1
2 files changed, 55 insertions, 1 deletions
diff --git a/config-model/src/test/java/com/yahoo/schema/derived/IndexInfoTestCase.java b/config-model/src/test/java/com/yahoo/schema/derived/IndexInfoTestCase.java
new file mode 100644
index 00000000000..09450fa8023
--- /dev/null
+++ b/config-model/src/test/java/com/yahoo/schema/derived/IndexInfoTestCase.java
@@ -0,0 +1,55 @@
+package com.yahoo.schema.derived;
+
+import com.yahoo.config.model.deploy.DeployState;
+import com.yahoo.search.config.IndexInfoConfig;
+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 org.junit.jupiter.api.Test;
+
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class IndexInfoTestCase {
+ private static final String F = "f";
+ @Test
+ void testThatIndexingEnablesNormalizing() {
+ var cmds = createIndexCmds(false);
+ assertEquals(8, cmds.size());
+ assertEquals(1, cmds.stream().filter(c -> c.indexname().equals(F) && c.command().equals("normalize")).count());
+ }
+ @Test
+ void testThatStreamingDisablesNormalizing() {
+ var cmds = createIndexCmds(true);
+ assertEquals(7, cmds.size());
+ assertEquals(0, cmds.stream().filter(c -> c.indexname().equals(F) && c.command().equals("normalize")).count());
+ }
+
+ private static List<IndexInfoConfig.Indexinfo.Command> createIndexCmds(boolean isStreaming) {
+ final String SD = "sda";
+ String documentContent = "field " + F + " type string {indexing:index | summary}";
+ var cfg = createIndexInfo(SD, documentContent, isStreaming);
+ assertEquals(SD, cfg.indexinfo(0).name());
+ return cfg.indexinfo(0).command();
+ }
+
+ private static IndexInfoConfig createIndexInfo(String schemaName, String sdContent, boolean isStreaming) {
+ var model = createModel(schemaName, sdContent);
+ var schema = model.getSearchClusters().get(0).schemas().get(schemaName);
+ var indexInfo = new IndexInfo(schema.fullSchema(), isStreaming);
+ IndexInfoConfig.Builder builder = new IndexInfoConfig.Builder();
+ indexInfo.getConfig(builder);
+ return builder.build();
+ }
+
+ private static VespaModel createModel(String schemaName, String sdContent) {
+ var builder = new DeployState.Builder();
+ return new ApplicationPackageBuilder()
+ .addCluster(new ContentClusterBuilder().name("content").docTypes(List.of(DocType.index(schemaName))))
+ .addSchemas(new SchemaBuilder().name(schemaName).content(sdContent).build())
+ .buildCreator().create(builder);
+ }
+}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/utils/SchemaBuilder.java b/config-model/src/test/java/com/yahoo/vespa/model/content/utils/SchemaBuilder.java
index 6defca17bcb..304f3dc426f 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/utils/SchemaBuilder.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/utils/SchemaBuilder.java
@@ -3,7 +3,6 @@ package com.yahoo.vespa.model.content.utils;
import java.util.Arrays;
import java.util.List;
-import java.util.stream.Collectors;
import static com.yahoo.config.model.test.TestUtil.joinLines;