aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/schema
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2023-11-03 15:11:23 +0100
committerTor Egge <Tor.Egge@online.no>2023-11-03 15:11:23 +0100
commit1383233bcd105bc13f3dd4dacada5f016fa8b3e8 (patch)
tree3828e50eb462128f3ca27e4335dd7845e1fcc223 /config-model/src/test/java/com/yahoo/schema
parent94052840f6ec8dabe2ed9f708afa89c8a06f215c (diff)
Write to summary field source.
Diffstat (limited to 'config-model/src/test/java/com/yahoo/schema')
-rw-r--r--config-model/src/test/java/com/yahoo/schema/processing/AddExtraFieldsToDocumentTest.java23
-rw-r--r--config-model/src/test/java/com/yahoo/schema/processing/IndexingOutputsTestCase.java19
-rw-r--r--config-model/src/test/java/com/yahoo/schema/processing/IndexingScriptRewriterTestCase.java2
3 files changed, 43 insertions, 1 deletions
diff --git a/config-model/src/test/java/com/yahoo/schema/processing/AddExtraFieldsToDocumentTest.java b/config-model/src/test/java/com/yahoo/schema/processing/AddExtraFieldsToDocumentTest.java
index 43b403c42c6..aad6df62993 100644
--- a/config-model/src/test/java/com/yahoo/schema/processing/AddExtraFieldsToDocumentTest.java
+++ b/config-model/src/test/java/com/yahoo/schema/processing/AddExtraFieldsToDocumentTest.java
@@ -49,6 +49,29 @@ public class AddExtraFieldsToDocumentTest {
assertNull(schema.getDocument().getField("my_c"));
}
+ @Test
+ public void testExtraFieldIsAddedWhenBeingASummarySource() throws ParseException {
+ var sd = """
+ search renamed {
+ document renamed {
+ field foo type string { }
+ }
+ field bar type string {
+ indexing: input foo | summary
+ summary baz { }
+ }
+ field bar2 type string {
+ indexing: input foo
+ summary baz2 { }
+ }
+ }
+ """;
+ var builder = ApplicationBuilder.createFromString(sd);
+ var schema = builder.getSchema();
+ assertNotNull(schema.getDocument().getDocumentType().getField("bar"));
+ assertNull(schema.getDocument().getDocumentType().getField("bar2"));
+ }
+
private void assertSummary(Schema schema, String dsName, String name, SummaryTransform transform, String source) {
var docsum = schema.getSummary(dsName);
var field = docsum.getSummaryField(name);
diff --git a/config-model/src/test/java/com/yahoo/schema/processing/IndexingOutputsTestCase.java b/config-model/src/test/java/com/yahoo/schema/processing/IndexingOutputsTestCase.java
index 58956b89a07..76680f4ce9a 100644
--- a/config-model/src/test/java/com/yahoo/schema/processing/IndexingOutputsTestCase.java
+++ b/config-model/src/test/java/com/yahoo/schema/processing/IndexingOutputsTestCase.java
@@ -62,4 +62,23 @@ public class IndexingOutputsTestCase {
}
}
+ @Test
+ void requireThatSummaryFieldSourceIsPopulated() throws ParseException {
+ var sd = """
+ search renamed {
+ document renamed {
+ field foo type string { }
+ }
+ field bar type string {
+ indexing: input foo | summary
+ summary baz { }
+ summary dyn_baz { dynamic }
+ }
+ }
+ """;
+ var builder = ApplicationBuilder.createFromString(sd);
+ var schema = builder.getSchema();
+ assertEquals("{ input foo | summary baz | summary dyn_baz | summary bar; }",
+ schema.getConcreteField("bar").getIndexingScript().toString());
+ }
}
diff --git a/config-model/src/test/java/com/yahoo/schema/processing/IndexingScriptRewriterTestCase.java b/config-model/src/test/java/com/yahoo/schema/processing/IndexingScriptRewriterTestCase.java
index b62fc61f5b7..0b561563421 100644
--- a/config-model/src/test/java/com/yahoo/schema/processing/IndexingScriptRewriterTestCase.java
+++ b/config-model/src/test/java/com/yahoo/schema/processing/IndexingScriptRewriterTestCase.java
@@ -48,7 +48,7 @@ public class IndexingScriptRewriterTestCase extends AbstractSchemaTestCase {
void testDynamicSummaryRewriting() {
SDField field = createField("test", DataType.STRING, "{ summary }");
field.addSummaryField(createDynamicSummaryField(field, "dyn"));
- assertIndexingScript("{ input test | summary dyn; }", field);
+ assertIndexingScript("{ input test | summary dyn | summary test; }", field);
}
@Test