summaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/searchdefinition/processing
diff options
context:
space:
mode:
Diffstat (limited to 'config-model/src/test/java/com/yahoo/searchdefinition/processing')
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/AddAttributeTransformToSummaryOfImportedFieldsTest.java35
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/AdjustPositionSummaryFieldsTestCase.java61
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/AssertIndexingScript.java6
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/AttributesExactMatchTestCase.java32
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/BoldingTestCase.java4
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/BoolAttributeValidatorTestCase.java7
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/DictionaryTestCase.java73
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/FastAccessValidatorTest.java6
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSchemaFieldsTestCase.java (renamed from config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSearchFieldsTestCase.java)36
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitStructTypesTestCase.java18
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSummariesTestCase.java18
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSummaryFieldsTestCase.java12
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsResolverTestCase.java69
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsTestCase.java120
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingInputsTestCase.java9
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingOutputsTestCase.java4
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingScriptRewriterTestCase.java14
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingValidationTestCase.java14
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingValuesTestCase.java2
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/IntegerIndex2AttributeTestCase.java30
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java11
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/NGramTestCase.java22
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/PagedAttributeValidatorTestCase.java5
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/ParentChildSearchModel.java27
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/PositionTestCase.java74
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/RankModifierTestCase.java8
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/RankProfileSearchFixture.java12
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/RankPropertyVariablesTestCase.java20
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTransformerTokensTestCase.java6
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionsTestCase.java40
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/ReferenceFieldTestCase.java8
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/ReservedDocumentNamesTestCase.java2
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/SchemaMustHaveDocumentTest.java (renamed from config-model/src/test/java/com/yahoo/searchdefinition/processing/SearchMustHaveDocumentTest.java)4
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/SummaryConsistencyTestCase.java6
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/SummaryFieldsMustHaveValidSourceTestCase.java18
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorFieldTestCase.java10
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java9
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/ValidateFieldTypesTest.java39
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/processing/WeightedSetSummaryToTestCase.java10
39 files changed, 455 insertions, 446 deletions
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AddAttributeTransformToSummaryOfImportedFieldsTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AddAttributeTransformToSummaryOfImportedFieldsTest.java
index f0fab8e4810..715b7b803e2 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AddAttributeTransformToSummaryOfImportedFieldsTest.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AddAttributeTransformToSummaryOfImportedFieldsTest.java
@@ -6,8 +6,9 @@ import com.yahoo.config.model.deploy.TestProperties;
import com.yahoo.config.model.test.MockApplicationPackage;
import com.yahoo.document.DataType;
import com.yahoo.document.Field;
+import com.yahoo.searchdefinition.Application;
import com.yahoo.searchdefinition.DocumentReference;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.derived.TestableDeployLogger;
import com.yahoo.searchdefinition.document.ImportedField;
import com.yahoo.searchdefinition.document.ImportedFields;
@@ -34,39 +35,39 @@ public class AddAttributeTransformToSummaryOfImportedFieldsTest {
@Test
public void attribute_summary_transform_applied_to_summary_field_of_imported_field() {
- Search search = createSearchWithDocument(DOCUMENT_NAME);
- search.setImportedFields(createSingleImportedField(IMPORTED_FIELD_NAME));
- search.addSummary(createDocumentSummary(IMPORTED_FIELD_NAME, search));
+ Schema schema = createSearchWithDocument(DOCUMENT_NAME);
+ schema.setImportedFields(createSingleImportedField(IMPORTED_FIELD_NAME));
+ schema.addSummary(createDocumentSummary(IMPORTED_FIELD_NAME, schema));
AddAttributeTransformToSummaryOfImportedFields processor = new AddAttributeTransformToSummaryOfImportedFields(
- search,null,null,null);
+ schema, null, null, null);
processor.process(true, false);
- SummaryField summaryField = search.getSummaries().get(SUMMARY_NAME).getSummaryField(IMPORTED_FIELD_NAME);
+ SummaryField summaryField = schema.getSummaries().get(SUMMARY_NAME).getSummaryField(IMPORTED_FIELD_NAME);
SummaryTransform actualTransform = summaryField.getTransform();
assertEquals(SummaryTransform.ATTRIBUTE, actualTransform);
}
- private static Search createSearch(String documentType) {
- return new Search(documentType, MockApplicationPackage.createEmpty(), new MockFileRegistry(), new TestableDeployLogger(), new TestProperties());
+ private static Schema createSearch(String documentType) {
+ return new Schema(documentType, new Application(MockApplicationPackage.createEmpty()), new MockFileRegistry(), new TestableDeployLogger(), new TestProperties());
}
- private static Search createSearchWithDocument(String documentName) {
- Search search = createSearch(documentName);
- SDDocumentType document = new SDDocumentType(documentName, search);
- search.addDocument(document);
- return search;
+ private static Schema createSearchWithDocument(String documentName) {
+ Schema schema = createSearch(documentName);
+ SDDocumentType document = new SDDocumentType(documentName, schema);
+ schema.addDocument(document);
+ return schema;
}
private static ImportedFields createSingleImportedField(String fieldName) {
- Search targetSearch = createSearch("target_doc");
+ Schema targetSchema = createSearch("target_doc");
SDField targetField = new SDField("target_field", DataType.INT);
- DocumentReference documentReference = new DocumentReference(new Field("reference_field"), targetSearch);
+ DocumentReference documentReference = new DocumentReference(new Field("reference_field"), targetSchema);
ImportedField importedField = new ImportedSimpleField(fieldName, documentReference, targetField);
return new ImportedFields(Collections.singletonMap(fieldName, importedField));
}
- private static DocumentSummary createDocumentSummary(String fieldName, Search search) {
- DocumentSummary summary = new DocumentSummary("mysummary", search);
+ private static DocumentSummary createDocumentSummary(String fieldName, Schema schema) {
+ DocumentSummary summary = new DocumentSummary("mysummary", schema);
summary.add(new SummaryField(fieldName, DataType.INT));
return summary;
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AdjustPositionSummaryFieldsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AdjustPositionSummaryFieldsTestCase.java
index f9796432de8..3b5add5b3d8 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AdjustPositionSummaryFieldsTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AdjustPositionSummaryFieldsTestCase.java
@@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.processing;
import com.yahoo.document.DataType;
import com.yahoo.document.PositionDataType;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.vespa.documentmodel.DocumentSummary;
import com.yahoo.vespa.documentmodel.SummaryField;
import com.yahoo.vespa.documentmodel.SummaryTransform;
@@ -73,7 +73,7 @@ public class AdjustPositionSummaryFieldsTestCase {
public void test_pos_default_summary_no_attr_no_rename() {
SearchModel model = new SearchModel(false, false, false);
model.resolve();
- assertNull(model.childSearch.getSummary("default")); // ImplicitSummaries processing not run in this test
+ assertNull(model.childSchema.getSummary("default")); // ImplicitSummaries processing not run in this test
}
@Test
@@ -92,8 +92,7 @@ public class AdjustPositionSummaryFieldsTestCase {
@Test
public void test_pos_summary_no_attr() {
exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage("For search 'child', field 'my_pos': "
- + "No position attribute 'pos_zcurve'");
+ exceptionRule.expectMessage("For schema 'child', field 'my_pos': No position attribute 'pos_zcurve'");
SearchModel model = new SearchModel(false, false, false);
model.addSummaryField("my_pos", PositionDataType.INSTANCE, null, "pos");
model.resolve();
@@ -102,8 +101,7 @@ public class AdjustPositionSummaryFieldsTestCase {
@Test
public void test_pos_summary_bad_attr() {
exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage("For search 'child', field 'my_pos': "
- + "No position attribute 'pos_zcurve'");
+ exceptionRule.expectMessage("For schema 'child', field 'my_pos': No position attribute 'pos_zcurve'");
SearchModel model = new SearchModel(false, false, true);
model.addSummaryField("my_pos", PositionDataType.INSTANCE, null, "pos");
model.resolve();
@@ -112,7 +110,7 @@ public class AdjustPositionSummaryFieldsTestCase {
@Test
public void test_imported_pos_summary_no_attr() {
exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage("For search 'child', import field 'my_pos_zcurve': "
+ exceptionRule.expectMessage("For schema 'child', import field 'my_pos_zcurve': "
+ "Field 'pos_zcurve' via reference field 'ref': Not found");
SearchModel model = new SearchModel(true, false, false);
model.addSummaryField("my_pos", PositionDataType.INSTANCE, null, null);
@@ -122,7 +120,7 @@ public class AdjustPositionSummaryFieldsTestCase {
@Test
public void test_imported_pos_summary_bad_attr() {
exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage("For search 'child', field 'my_pos': "
+ exceptionRule.expectMessage("For schema 'child', field 'my_pos': "
+ "No position attribute 'my_pos_zcurve'");
SearchModel model = new SearchModel(true, false, true);
model.addSummaryField("my_pos", PositionDataType.INSTANCE, null, null);
@@ -132,7 +130,7 @@ public class AdjustPositionSummaryFieldsTestCase {
@Test
public void test_my_pos_position_summary_bad_datatype() {
exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage("For search 'child', field 'my_pos.position': "
+ exceptionRule.expectMessage("For schema 'child', field 'my_pos.position': "
+ "exists with type 'datatype string (code: 2)', should be of type 'datatype Array<string> (code: -1486737430)");
SearchModel model = new SearchModel();
model.addSummaryField("my_pos", PositionDataType.INSTANCE, null, null);
@@ -143,7 +141,7 @@ public class AdjustPositionSummaryFieldsTestCase {
@Test
public void test_my_pos_position_summary_bad_transform() {
exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage("For search 'child', field 'my_pos.position': "
+ exceptionRule.expectMessage("For schema 'child', field 'my_pos.position': "
+ "has summary transform 'none', should have transform 'positions'");
SearchModel model = new SearchModel();
model.addSummaryField("my_pos", PositionDataType.INSTANCE, null, null);
@@ -154,7 +152,7 @@ public class AdjustPositionSummaryFieldsTestCase {
@Test
public void test_my_pos_position_summary_bad_source() {
exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage("For search 'child', field 'my_pos.position': "
+ exceptionRule.expectMessage("For schema 'child', field 'my_pos.position': "
+ "has source '[source field 'pos']', should have source 'source field 'my_pos_zcurve''");
SearchModel model = new SearchModel();
model.addSummaryField("my_pos", PositionDataType.INSTANCE, null, null);
@@ -175,21 +173,21 @@ public class AdjustPositionSummaryFieldsTestCase {
SearchModel(boolean importedPos, boolean setupPosAttr, boolean setupBadAttr) {
super();
if (importedPos) {
- createPositionField(parentSearch, setupPosAttr, setupBadAttr);
+ createPositionField(parentSchema, setupPosAttr, setupBadAttr);
}
- addRefField(childSearch, parentSearch, "ref");
+ addRefField(childSchema, parentSchema, "ref");
if (importedPos) {
addImportedField("my_pos", "ref", "pos");
} else {
- createPositionField(childSearch, setupPosAttr, setupBadAttr);
+ createPositionField(childSchema, setupPosAttr, setupBadAttr);
}
}
- private void createPositionField(Search search, boolean setupPosAttr, boolean setupBadAttr) {
+ private void createPositionField(Schema schema, boolean setupPosAttr, boolean setupBadAttr) {
String ilScript = setupPosAttr ? "{ summary | attribute }" : "{ summary }";
- search.getDocument().addField(createField("pos", PositionDataType.INSTANCE, ilScript));
+ schema.getDocument().addField(createField("pos", PositionDataType.INSTANCE, ilScript));
if (setupBadAttr) {
- search.getDocument().addField(createField("pos_zcurve", DataType.LONG, "{ attribute }"));
+ schema.getDocument().addField(createField("pos_zcurve", DataType.LONG, "{ attribute }"));
}
}
@@ -198,10 +196,10 @@ public class AdjustPositionSummaryFieldsTestCase {
}
public void addSummaryField(String summaryName, String fieldName, DataType dataType, SummaryTransform transform, String source) {
- DocumentSummary summary = childSearch.getSummary(summaryName);
+ DocumentSummary summary = childSchema.getSummary(summaryName);
if (summary == null) {
- summary = new DocumentSummary(summaryName, childSearch);
- childSearch.addSummary(summary);
+ summary = new DocumentSummary(summaryName, childSchema);
+ childSchema.addSummary(summary);
}
SummaryField summaryField = new SummaryField(fieldName, dataType);
if (source != null) {
@@ -218,7 +216,7 @@ public class AdjustPositionSummaryFieldsTestCase {
}
public void assertNoSummaryField(String summaryName, String fieldName) {
- DocumentSummary summary = childSearch.getSummary(summaryName);
+ DocumentSummary summary = childSchema.getSummary(summaryName);
assertNotNull(summary);
SummaryField summaryField = summary.getSummaryField(fieldName);
assertNull(summaryField);
@@ -229,7 +227,7 @@ public class AdjustPositionSummaryFieldsTestCase {
}
public void assertSummaryField(String summaryName, String fieldName, DataType dataType, SummaryTransform transform, String source) {
- DocumentSummary summary = childSearch.getSummary(summaryName);
+ DocumentSummary summary = childSchema.getSummary(summaryName);
assertNotNull(summary);
SummaryField summaryField = summary.getSummaryField(fieldName);
assertNotNull(summaryField);
@@ -244,18 +242,17 @@ public class AdjustPositionSummaryFieldsTestCase {
}
public void resolve() {
- resolve(parentSearch);
- resolve(childSearch);
+ resolve(parentSchema);
+ resolve(childSchema);
}
- private static void resolve(Search search) {
- new CreatePositionZCurve(search, null, null, null).process(true, false);
- assertNotNull(search.temporaryImportedFields().get());
- assertFalse(search.importedFields().isPresent());
- new ImportedFieldsResolver(search, null, null, null).process(true, false);
- assertFalse(search.temporaryImportedFields().isPresent());
- assertNotNull(search.importedFields().get());
- new AdjustPositionSummaryFields(search, null, null, null).process(true, false);
+ private static void resolve(Schema schema) {
+ new CreatePositionZCurve(schema, null, null, null).process(true, false);
+ assertNotNull(schema.temporaryImportedFields().get());
+ assertFalse(schema.importedFields().isPresent());
+ new ImportedFieldsResolver(schema, null, null, null).process(true, false);
+ assertNotNull(schema.importedFields().get());
+ new AdjustPositionSummaryFields(schema, null, null, null).process(true, false);
}
}
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AssertIndexingScript.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AssertIndexingScript.java
index c9f9e8c50f9..8a0c1e2fe71 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AssertIndexingScript.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AssertIndexingScript.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.processing;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.derived.IndexingScript;
import com.yahoo.vespa.indexinglanguage.expressions.Expression;
import com.yahoo.vespa.indexinglanguage.parser.ParseException;
@@ -17,8 +17,8 @@ import static org.junit.Assert.fail;
*/
public abstract class AssertIndexingScript {
- public static void assertIndexing(List<String> expected, Search search) {
- assertIndexing(expected, new IndexingScript(search).expressions());
+ public static void assertIndexing(List<String> expected, Schema schema) {
+ assertIndexing(expected, new IndexingScript(schema).expressions());
}
public static void assertIndexing(List<String> expected, IndexingScript script) {
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AttributesExactMatchTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AttributesExactMatchTestCase.java
index 7f72cc96ccf..57e01cb9dfc 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AttributesExactMatchTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AttributesExactMatchTestCase.java
@@ -1,9 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.processing;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.SearchBuilder;
-import com.yahoo.searchdefinition.SchemaTestCase;
+import com.yahoo.searchdefinition.AbstractSchemaTestCase;
import com.yahoo.searchdefinition.document.Matching;
import com.yahoo.searchdefinition.parser.ParseException;
import org.junit.Test;
@@ -17,23 +17,23 @@ import static org.junit.Assert.assertFalse;
* @author vegardh
*
*/
-public class AttributesExactMatchTestCase extends SchemaTestCase {
+public class AttributesExactMatchTestCase extends AbstractSchemaTestCase {
@Test
public void testAttributesExactMatch() throws IOException, ParseException {
- Search search = SearchBuilder.buildFromFile("src/test/examples/attributesexactmatch.sd");
- assertEquals(search.getConcreteField("color").getMatching().getType(), Matching.Type.EXACT);
- assertEquals(search.getConcreteField("artist").getMatching().getType(), Matching.Type.WORD);
- assertEquals(search.getConcreteField("drummer").getMatching().getType(), Matching.Type.WORD);
- assertEquals(search.getConcreteField("guitarist").getMatching().getType(), Matching.Type.TEXT);
- assertEquals(search.getConcreteField("saxophonist_arr").getMatching().getType(), Matching.Type.WORD);
- assertEquals(search.getConcreteField("flutist").getMatching().getType(), Matching.Type.TEXT);
+ Schema schema = SearchBuilder.buildFromFile("src/test/examples/attributesexactmatch.sd");
+ assertEquals(schema.getConcreteField("color").getMatching().getType(), Matching.Type.EXACT);
+ assertEquals(schema.getConcreteField("artist").getMatching().getType(), Matching.Type.WORD);
+ assertEquals(schema.getConcreteField("drummer").getMatching().getType(), Matching.Type.WORD);
+ assertEquals(schema.getConcreteField("guitarist").getMatching().getType(), Matching.Type.TEXT);
+ assertEquals(schema.getConcreteField("saxophonist_arr").getMatching().getType(), Matching.Type.WORD);
+ assertEquals(schema.getConcreteField("flutist").getMatching().getType(), Matching.Type.TEXT);
- assertFalse(search.getConcreteField("genre").getMatching().getType().equals(Matching.Type.EXACT));
- assertFalse(search.getConcreteField("title").getMatching().getType().equals(Matching.Type.EXACT));
- assertFalse(search.getConcreteField("trumpetist").getMatching().getType().equals(Matching.Type.EXACT));
- assertFalse(search.getConcreteField("genre").getMatching().getType().equals(Matching.Type.WORD));
- assertFalse(search.getConcreteField("title").getMatching().getType().equals(Matching.Type.WORD));
- assertFalse(search.getConcreteField("trumpetist").getMatching().getType().equals(Matching.Type.WORD));
+ assertFalse(schema.getConcreteField("genre").getMatching().getType().equals(Matching.Type.EXACT));
+ assertFalse(schema.getConcreteField("title").getMatching().getType().equals(Matching.Type.EXACT));
+ assertFalse(schema.getConcreteField("trumpetist").getMatching().getType().equals(Matching.Type.EXACT));
+ assertFalse(schema.getConcreteField("genre").getMatching().getType().equals(Matching.Type.WORD));
+ assertFalse(schema.getConcreteField("title").getMatching().getType().equals(Matching.Type.WORD));
+ assertFalse(schema.getConcreteField("trumpetist").getMatching().getType().equals(Matching.Type.WORD));
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoldingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoldingTestCase.java
index 288987e0f2f..d9d8e47338b 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoldingTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoldingTestCase.java
@@ -2,7 +2,7 @@
package com.yahoo.searchdefinition.processing;
import com.yahoo.searchdefinition.SearchBuilder;
-import com.yahoo.searchdefinition.SchemaTestCase;
+import com.yahoo.searchdefinition.AbstractSchemaTestCase;
import com.yahoo.searchdefinition.parser.ParseException;
import org.junit.Test;
@@ -12,7 +12,7 @@ import static org.junit.Assert.fail;
/**
* @author bratseth
*/
-public class BoldingTestCase extends SchemaTestCase {
+public class BoldingTestCase extends AbstractSchemaTestCase {
private final String boldonnonstring =
"search boldnonstring {\n" +
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoolAttributeValidatorTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoolAttributeValidatorTestCase.java
index a50af793bc4..fbfb46be558 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoolAttributeValidatorTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/BoolAttributeValidatorTestCase.java
@@ -21,7 +21,7 @@ public class BoolAttributeValidatorTestCase {
fail("Expected exception");
}
catch (IllegalArgumentException e) {
- assertEquals("For search 'test', field 'b': Only single value bool attribute fields are supported",
+ assertEquals("For schema 'test', field 'b': Only single value bool attribute fields are supported",
e.getMessage());
}
}
@@ -33,13 +33,14 @@ public class BoolAttributeValidatorTestCase {
fail("Expected exception");
}
catch (IllegalArgumentException e) {
- assertEquals("For search 'test', field 'b': Only single value bool attribute fields are supported",
+ assertEquals("For schema 'test', field 'b': Only single value bool attribute fields are supported",
e.getMessage());
}
}
private String getSd(String field) {
- return joinLines("search test {",
+ return joinLines(
+ "schema test {",
" document test {",
" " + field,
" }",
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/DictionaryTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/DictionaryTestCase.java
index db87ae698b4..20ff10cb48e 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/DictionaryTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/DictionaryTestCase.java
@@ -3,13 +3,12 @@
package com.yahoo.searchdefinition.processing;
import com.yahoo.config.model.test.TestUtil;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.SearchBuilder;
import com.yahoo.searchdefinition.derived.AttributeFields;
import com.yahoo.searchdefinition.document.Case;
import com.yahoo.searchdefinition.document.Dictionary;
import com.yahoo.searchdefinition.document.ImmutableSDField;
-import com.yahoo.searchdefinition.document.Matching;
import com.yahoo.searchdefinition.parser.ParseException;
import com.yahoo.vespa.config.search.AttributesConfig;
import org.junit.Test;
@@ -24,13 +23,13 @@ import static org.junit.Assert.fail;
* @author baldersheim
*/
public class DictionaryTestCase {
- private static AttributesConfig getConfig(Search search) {
- AttributeFields attributes = new AttributeFields(search);
+ private static AttributesConfig getConfig(Schema schema) {
+ AttributeFields attributes = new AttributeFields(schema);
AttributesConfig.Builder builder = new AttributesConfig.Builder();
attributes.getConfig(builder);
return builder.build();
}
- private Search createSearch(String def) throws ParseException {
+ private Schema createSearch(String def) throws ParseException {
SearchBuilder sb = SearchBuilder.createFromString(def);
return sb.getSearch();
}
@@ -47,20 +46,20 @@ public class DictionaryTestCase {
" }",
" }",
"}");
- Search search = createSearch(def);
- assertNull(search.getAttribute("s1").getDictionary());
- assertNull(search.getAttribute("n1").getDictionary());
+ Schema schema = createSearch(def);
+ assertNull(schema.getAttribute("s1").getDictionary());
+ assertNull(schema.getAttribute("n1").getDictionary());
assertEquals(AttributesConfig.Attribute.Dictionary.Type.BTREE,
- getConfig(search).attribute().get(0).dictionary().type());
+ getConfig(schema).attribute().get(0).dictionary().type());
assertEquals(AttributesConfig.Attribute.Dictionary.Type.BTREE,
- getConfig(search).attribute().get(1).dictionary().type());
+ getConfig(schema).attribute().get(1).dictionary().type());
assertEquals(AttributesConfig.Attribute.Dictionary.Match.UNCASED,
- getConfig(search).attribute().get(0).dictionary().match());
+ getConfig(schema).attribute().get(0).dictionary().match());
assertEquals(AttributesConfig.Attribute.Dictionary.Match.UNCASED,
- getConfig(search).attribute().get(1).dictionary().match());
+ getConfig(schema).attribute().get(1).dictionary().match());
}
- Search verifyDictionaryControl(Dictionary.Type expected, String type, String ... cfg) throws ParseException
+ Schema verifyDictionaryControl(Dictionary.Type expected, String type, String ... cfg) throws ParseException
{
String def = TestUtil.joinLines(
"search test {",
@@ -72,11 +71,11 @@ public class DictionaryTestCase {
" }",
" }",
"}");
- Search search = createSearch(def);
+ Schema schema = createSearch(def);
AttributesConfig.Attribute.Dictionary.Type.Enum expectedConfig = toCfg(expected);
- assertEquals(expected, search.getAttribute("n1").getDictionary().getType());
- assertEquals(expectedConfig, getConfig(search).attribute().get(0).dictionary().type());
- return search;
+ assertEquals(expected, schema.getAttribute("n1").getDictionary().getType());
+ assertEquals(expectedConfig, getConfig(schema).attribute().get(0).dictionary().type());
+ return schema;
}
AttributesConfig.Attribute.Dictionary.Type.Enum toCfg(Dictionary.Type v) {
@@ -95,12 +94,12 @@ public class DictionaryTestCase {
void verifyStringDictionaryControl(Dictionary.Type expectedType, Case expectedCase, Case matchCasing,
String ... cfg) throws ParseException
{
- Search search = verifyDictionaryControl(expectedType, "string", cfg);
- ImmutableSDField f = search.getField("n1");
+ Schema schema = verifyDictionaryControl(expectedType, "string", cfg);
+ ImmutableSDField f = schema.getField("n1");
AttributesConfig.Attribute.Dictionary.Match.Enum expectedCaseCfg = toCfg(expectedCase);
assertEquals(matchCasing, f.getMatching().getCase());
- assertEquals(expectedCase, search.getAttribute("n1").getDictionary().getMatch());
- assertEquals(expectedCaseCfg, getConfig(search).attribute().get(0).dictionary().match());
+ assertEquals(expectedCase, schema.getAttribute("n1").getDictionary().getMatch());
+ assertEquals(expectedCaseCfg, getConfig(schema).attribute().get(0).dictionary().match());
}
@Test
@@ -145,7 +144,7 @@ public class DictionaryTestCase {
try {
verifyStringDictionaryControl(Dictionary.Type.HASH, Case.UNCASED, Case.UNCASED, "dictionary:hash");
} catch (IllegalArgumentException e) {
- assertEquals("For search 'test', field 'n1': hash dictionary require cased match", e.getMessage());
+ assertEquals("For schema 'test', field 'n1': hash dictionary require cased match", e.getMessage());
}
}
@Test
@@ -153,7 +152,7 @@ public class DictionaryTestCase {
try {
verifyStringDictionaryControl(Dictionary.Type.HASH, Case.UNCASED, Case.UNCASED, "dictionary { hash\nuncased\n}");
} catch (IllegalArgumentException e) {
- assertEquals("For search 'test', field 'n1': hash dictionary require cased match", e.getMessage());
+ assertEquals("For schema 'test', field 'n1': hash dictionary require cased match", e.getMessage());
}
}
@Test
@@ -166,7 +165,7 @@ public class DictionaryTestCase {
verifyStringDictionaryControl(Dictionary.Type.HASH, Case.CASED, Case.CASED, "dictionary { hash\ncased\n}");
fail();
} catch (IllegalArgumentException e) {
- assertEquals("For search 'test', field 'n1': Dictionary casing 'CASED' does not match field match casing 'UNCASED'", e.getMessage());
+ assertEquals("For schema 'test', field 'n1': Dictionary casing 'CASED' does not match field match casing 'UNCASED'", e.getMessage());
}
}
@Test
@@ -182,13 +181,13 @@ public class DictionaryTestCase {
try {
verifyStringDictionaryControl(Dictionary.Type.BTREE_AND_HASH, Case.CASED, Case.CASED, "dictionary { btree\nhash\ncased\n}");
} catch (IllegalArgumentException e) {
- assertEquals("For search 'test', field 'n1': Dictionary casing 'CASED' does not match field match casing 'UNCASED'", e.getMessage());
+ assertEquals("For schema 'test', field 'n1': Dictionary casing 'CASED' does not match field match casing 'UNCASED'", e.getMessage());
}
}
@Test
public void testNonNumericFieldsFailsDictionaryControl() throws ParseException {
String def = TestUtil.joinLines(
- "search test {",
+ "schema test {",
" document test {",
" field n1 type bool {",
" indexing: summary | attribute",
@@ -200,13 +199,13 @@ public class DictionaryTestCase {
SearchBuilder sb = SearchBuilder.createFromString(def);
fail("Controlling dictionary for non-numeric fields are not yet supported.");
} catch (IllegalArgumentException e) {
- assertEquals("For search 'test', field 'n1': You can only specify 'dictionary:' for numeric or string fields", e.getMessage());
+ assertEquals("For schema 'test', field 'n1': You can only specify 'dictionary:' for numeric or string fields", e.getMessage());
}
}
@Test
public void testNonFastSearchNumericFieldsFailsDictionaryControl() throws ParseException {
String def = TestUtil.joinLines(
- "search test {",
+ "schema test {",
" document test {",
" field n1 type int {",
" indexing: summary | attribute",
@@ -218,14 +217,14 @@ public class DictionaryTestCase {
SearchBuilder sb = SearchBuilder.createFromString(def);
fail("Controlling dictionary for non-fast-search fields are not allowed.");
} catch (IllegalArgumentException e) {
- assertEquals("For search 'test', field 'n1': You must specify 'attribute:fast-search' to allow dictionary control", e.getMessage());
+ assertEquals("For schema 'test', field 'n1': You must specify 'attribute:fast-search' to allow dictionary control", e.getMessage());
}
}
@Test
public void testCasingForNonFastSearch() throws ParseException {
String def = TestUtil.joinLines(
- "search test {",
+ "schema test {",
" document test {",
" field s1 type string {",
" indexing: attribute | summary",
@@ -240,12 +239,12 @@ public class DictionaryTestCase {
" }",
" }",
"}");
- Search search = createSearch(def);
- assertEquals(Case.UNCASED, search.getAttribute("s1").getCase());
- assertEquals(Case.UNCASED, search.getAttribute("s2").getCase());
- assertEquals(Case.CASED, search.getAttribute("s3").getCase());
- assertEquals(AttributesConfig.Attribute.Match.UNCASED, getConfig(search).attribute().get(0).match());
- assertEquals(AttributesConfig.Attribute.Match.UNCASED, getConfig(search).attribute().get(1).match());
- assertEquals(AttributesConfig.Attribute.Match.CASED, getConfig(search).attribute().get(2).match());
+ Schema schema = createSearch(def);
+ assertEquals(Case.UNCASED, schema.getAttribute("s1").getCase());
+ assertEquals(Case.UNCASED, schema.getAttribute("s2").getCase());
+ assertEquals(Case.CASED, schema.getAttribute("s3").getCase());
+ assertEquals(AttributesConfig.Attribute.Match.UNCASED, getConfig(schema).attribute().get(0).match());
+ assertEquals(AttributesConfig.Attribute.Match.UNCASED, getConfig(schema).attribute().get(1).match());
+ assertEquals(AttributesConfig.Attribute.Match.CASED, getConfig(schema).attribute().get(2).match());
}
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/FastAccessValidatorTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/FastAccessValidatorTest.java
index c889a8ccd34..0a9807e0746 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/FastAccessValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/FastAccessValidatorTest.java
@@ -22,14 +22,14 @@ public class FastAccessValidatorTest {
SearchBuilder builder = new SearchBuilder(new RankProfileRegistry());
builder.importString(
TestUtil.joinLines(
- "search parent {",
+ "schema parent {",
" document parent {",
" field int_field type int { indexing: attribute }",
" }",
"}"));
builder.importString(
TestUtil.joinLines(
- "search test {",
+ "schema test {",
" document test { ",
" field int_attribute type int { ",
" indexing: attribute ",
@@ -51,7 +51,7 @@ public class FastAccessValidatorTest {
"}"));
exceptionRule.expect(IllegalArgumentException.class);
exceptionRule.expectMessage(
- "For search 'test': The following attributes have a type that is incompatible " +
+ "For schema 'test': The following attributes have a type that is incompatible " +
"with fast-access: predicate_attribute, tensor_attribute, reference_attribute. " +
"Predicate, tensor and reference attributes are incompatible with fast-access.");
builder.build();
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSearchFieldsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSchemaFieldsTestCase.java
index 5ef2f2842e1..dffc0d968df 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSearchFieldsTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSchemaFieldsTestCase.java
@@ -1,9 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.processing;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.SearchBuilder;
-import com.yahoo.searchdefinition.SchemaTestCase;
+import com.yahoo.searchdefinition.AbstractSchemaTestCase;
import com.yahoo.searchdefinition.derived.DerivedConfiguration;
import com.yahoo.searchdefinition.document.SDDocumentType;
import com.yahoo.searchdefinition.parser.ParseException;
@@ -14,14 +14,14 @@ import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-public class ImplicitSearchFieldsTestCase extends SchemaTestCase {
+public class ImplicitSchemaFieldsTestCase extends AbstractSchemaTestCase {
@Test
public void testRequireThatExtraFieldsAreIncluded() throws IOException, ParseException {
- Search search = SearchBuilder.buildFromFile("src/test/examples/nextgen/extrafield.sd");
- assertNotNull(search);
+ Schema schema = SearchBuilder.buildFromFile("src/test/examples/nextgen/extrafield.sd");
+ assertNotNull(schema);
- SDDocumentType docType = search.getDocument();
+ SDDocumentType docType = schema.getDocument();
assertNotNull(docType);
assertNotNull(docType.getField("foo"));
assertNotNull(docType.getField("bar"));
@@ -30,10 +30,10 @@ public class ImplicitSearchFieldsTestCase extends SchemaTestCase {
@Test
public void testRequireThatSummaryFieldsAreIncluded() throws IOException, ParseException {
- Search search = SearchBuilder.buildFromFile("src/test/examples/nextgen/summaryfield.sd");
- assertNotNull(search);
+ Schema schema = SearchBuilder.buildFromFile("src/test/examples/nextgen/summaryfield.sd");
+ assertNotNull(schema);
- SDDocumentType docType = search.getDocument();
+ SDDocumentType docType = schema.getDocument();
assertNotNull(docType);
assertNotNull(docType.getField("foo"));
assertNotNull(docType.getField("bar"));
@@ -43,10 +43,10 @@ public class ImplicitSearchFieldsTestCase extends SchemaTestCase {
@Test
public void testRequireThatBoldedSummaryFieldsAreIncluded() throws IOException, ParseException {
- Search search = SearchBuilder.buildFromFile("src/test/examples/nextgen/boldedsummaryfields.sd");
- assertNotNull(search);
+ Schema schema = SearchBuilder.buildFromFile("src/test/examples/nextgen/boldedsummaryfields.sd");
+ assertNotNull(schema);
- SDDocumentType docType = search.getDocument();
+ SDDocumentType docType = schema.getDocument();
assertNotNull(docType);
assertNotNull(docType.getField("foo"));
assertNotNull(docType.getField("bar"));
@@ -57,10 +57,10 @@ public class ImplicitSearchFieldsTestCase extends SchemaTestCase {
@Test
public void testRequireThatUntransformedSummaryFieldsAreIgnored() throws IOException, ParseException {
- Search search = SearchBuilder.buildFromFile("src/test/examples/nextgen/untransformedsummaryfields.sd");
- assertNotNull(search);
+ Schema schema = SearchBuilder.buildFromFile("src/test/examples/nextgen/untransformedsummaryfields.sd");
+ assertNotNull(schema);
- SDDocumentType docType = search.getDocument();
+ SDDocumentType docType = schema.getDocument();
assertNotNull(docType);
assertNotNull(docType.getField("foo"));
assertNotNull(docType.getField("bar"));
@@ -70,10 +70,10 @@ public class ImplicitSearchFieldsTestCase extends SchemaTestCase {
@Test
public void testRequireThatDynamicSummaryFieldsAreIgnored() throws IOException, ParseException {
- Search search = SearchBuilder.buildFromFile("src/test/examples/nextgen/dynamicsummaryfields.sd");
- assertNotNull(search);
+ Schema schema = SearchBuilder.buildFromFile("src/test/examples/nextgen/dynamicsummaryfields.sd");
+ assertNotNull(schema);
- SDDocumentType docType = search.getDocument();
+ SDDocumentType docType = schema.getDocument();
assertNotNull(docType);
assertNotNull(docType.getField("foo"));
assertNotNull(docType.getField("bar"));
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitStructTypesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitStructTypesTestCase.java
index fb0f1bc2ba2..b069f62ee92 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitStructTypesTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitStructTypesTestCase.java
@@ -2,9 +2,9 @@
package com.yahoo.searchdefinition.processing;
import com.yahoo.document.*;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.SearchBuilder;
-import com.yahoo.searchdefinition.SchemaTestCase;
+import com.yahoo.searchdefinition.AbstractSchemaTestCase;
import com.yahoo.searchdefinition.document.SDDocumentType;
import com.yahoo.searchdefinition.document.SDField;
import com.yahoo.searchdefinition.parser.ParseException;
@@ -13,22 +13,22 @@ import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.*;
-public class ImplicitStructTypesTestCase extends SchemaTestCase {
+public class ImplicitStructTypesTestCase extends AbstractSchemaTestCase {
@Test
public void testRequireThatImplicitStructsAreCreated() throws IOException, ParseException {
- Search search = SearchBuilder.buildFromFile("src/test/examples/nextgen/toggleon.sd");
- assertNotNull(search);
+ Schema schema = SearchBuilder.buildFromFile("src/test/examples/nextgen/toggleon.sd");
+ assertNotNull(schema);
- SDDocumentType docType = search.getDocument();
+ SDDocumentType docType = schema.getDocument();
assertNotNull(docType);
assertStruct(docType, PositionDataType.INSTANCE);
}
@Test
public void testRequireThatImplicitStructsAreUsed() throws IOException, ParseException {
- Search search = SearchBuilder.buildFromFile("src/test/examples/nextgen/implicitstructtypes.sd");
- assertNotNull(search);
+ Schema schema = SearchBuilder.buildFromFile("src/test/examples/nextgen/implicitstructtypes.sd");
+ assertNotNull(schema);
- SDDocumentType docType = search.getDocument();
+ SDDocumentType docType = schema.getDocument();
assertNotNull(docType);
assertField(docType, "doc_str", DataType.STRING);
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSummariesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSummariesTestCase.java
index d45d366ee0a..9f4008b5b39 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSummariesTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSummariesTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.processing;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.SearchBuilder;
import com.yahoo.searchdefinition.parser.ParseException;
import com.yahoo.vespa.documentmodel.SummaryTransform;
@@ -29,8 +29,8 @@ public class ImplicitSummariesTestCase {
LogHandler log = new LogHandler();
Logger.getLogger("").addHandler(log);
- Search search = SearchBuilder.buildFromFile("src/test/examples/implicitsummaries_attribute.sd");
- assertNotNull(search);
+ Schema schema = SearchBuilder.buildFromFile("src/test/examples/implicitsummaries_attribute.sd");
+ assertNotNull(schema);
assertTrue(log.records.isEmpty());
}
@@ -60,19 +60,19 @@ public class ImplicitSummariesTestCase {
@Test
public void attribute_combiner_transform_is_set_on_array_of_struct_with_only_struct_field_attributes() throws IOException, ParseException {
- Search search = SearchBuilder.buildFromFile("src/test/derived/array_of_struct_attribute/test.sd");
- assertEquals(SummaryTransform.ATTRIBUTECOMBINER, search.getSummaryField("elem_array").getTransform());
+ Schema schema = SearchBuilder.buildFromFile("src/test/derived/array_of_struct_attribute/test.sd");
+ assertEquals(SummaryTransform.ATTRIBUTECOMBINER, schema.getSummaryField("elem_array").getTransform());
}
@Test
public void attribute_combiner_transform_is_set_on_map_of_struct_with_only_struct_field_attributes() throws IOException, ParseException {
- Search search = SearchBuilder.buildFromFile("src/test/derived/map_of_struct_attribute/test.sd");
- assertEquals(SummaryTransform.ATTRIBUTECOMBINER, search.getSummaryField("str_elem_map").getTransform());
+ Schema schema = SearchBuilder.buildFromFile("src/test/derived/map_of_struct_attribute/test.sd");
+ assertEquals(SummaryTransform.ATTRIBUTECOMBINER, schema.getSummaryField("str_elem_map").getTransform());
}
@Test
public void attribute_combiner_transform_is_not_set_when_map_of_struct_has_some_struct_field_attributes() throws IOException, ParseException {
- Search search = SearchBuilder.buildFromFile("src/test/derived/map_of_struct_attribute/test.sd");
- assertEquals(SummaryTransform.NONE, search.getSummaryField("int_elem_map").getTransform());
+ Schema schema = SearchBuilder.buildFromFile("src/test/derived/map_of_struct_attribute/test.sd");
+ assertEquals(SummaryTransform.NONE, schema.getSummaryField("int_elem_map").getTransform());
}
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSummaryFieldsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSummaryFieldsTestCase.java
index b7707f2a517..c9f941087ef 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSummaryFieldsTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSummaryFieldsTestCase.java
@@ -1,9 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.processing;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.SearchBuilder;
-import com.yahoo.searchdefinition.SchemaTestCase;
+import com.yahoo.searchdefinition.AbstractSchemaTestCase;
import com.yahoo.searchdefinition.parser.ParseException;
import com.yahoo.vespa.documentmodel.DocumentSummary;
import org.junit.Test;
@@ -13,14 +13,14 @@ import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-public class ImplicitSummaryFieldsTestCase extends SchemaTestCase {
+public class ImplicitSummaryFieldsTestCase extends AbstractSchemaTestCase {
@Test
public void testRequireThatImplicitFieldsAreCreated() throws IOException, ParseException {
- Search search = SearchBuilder.buildFromFile("src/test/examples/implicitsummaryfields.sd");
- assertNotNull(search);
+ Schema schema = SearchBuilder.buildFromFile("src/test/examples/implicitsummaryfields.sd");
+ assertNotNull(schema);
- DocumentSummary docsum = search.getSummary("default");
+ DocumentSummary docsum = schema.getSummary("default");
assertNotNull(docsum);
assertNotNull(docsum.getSummaryField("rankfeatures"));
assertNotNull(docsum.getSummaryField("summaryfeatures"));
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsResolverTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsResolverTestCase.java
index 3aeba7cd265..522d4dc2b15 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsResolverTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsResolverTestCase.java
@@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.processing;
import com.yahoo.document.DataType;
import com.yahoo.document.TensorDataType;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.document.ImmutableImportedSDField;
import com.yahoo.searchdefinition.document.ImmutableSDField;
import com.yahoo.searchdefinition.document.ImportedField;
@@ -36,9 +36,9 @@ public class ImportedFieldsResolverTestCase {
ImportedField myField = model.importedFields.fields().get(fieldName);
assertNotNull(myField);
assertEquals(fieldName, myField.fieldName());
- assertSame(model.childSearch.getConcreteField("ref"), myField.reference().referenceField());
- assertSame(model.parentSearch, myField.reference().targetSearch());
- ImmutableSDField targetField = model.parentSearch.getField(targetFieldName);
+ assertSame(model.childSchema.getConcreteField("ref"), myField.reference().referenceField());
+ assertSame(model.parentSchema, myField.reference().targetSearch());
+ ImmutableSDField targetField = model.parentSchema.getField(targetFieldName);
if (targetField instanceof SDField) {
assertSame(targetField, myField.targetField());
} else {
@@ -60,7 +60,7 @@ public class ImportedFieldsResolverTestCase {
@Test
public void resolver_fails_if_document_reference_is_not_found() {
exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage("For search 'child', import field 'my_attribute_field': "
+ exceptionRule.expectMessage("For schema 'child', import field 'my_attribute_field': "
+ "Reference field 'not_ref' not found");
new SearchModel().addImportedField("my_attribute_field", "not_ref", "budget").resolve();
}
@@ -68,7 +68,7 @@ public class ImportedFieldsResolverTestCase {
@Test
public void resolver_fails_if_referenced_field_is_not_found() {
exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage("For search 'child', import field 'my_attribute_field': "
+ exceptionRule.expectMessage("For schema 'child', import field 'my_attribute_field': "
+ "Field 'not_existing' via reference field 'ref': Not found");
new SearchModel().addImportedField("my_attribute_field", "ref", "not_existing").resolve();
}
@@ -76,7 +76,7 @@ public class ImportedFieldsResolverTestCase {
@Test
public void resolver_fails_if_imported_field_is_not_an_attribute() {
exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage("For search 'child', import field 'my_not_attribute': "
+ exceptionRule.expectMessage("For schema 'child', import field 'my_not_attribute': "
+ "Field 'not_attribute' via reference field 'ref': Is not an attribute field. Only attribute fields supported");
new SearchModel().addImportedField("my_not_attribute", "ref", "not_attribute").resolve();
}
@@ -85,7 +85,7 @@ public class ImportedFieldsResolverTestCase {
public void resolver_fails_if_imported_field_is_indexing() {
exceptionRule.expect(IllegalArgumentException.class);
exceptionRule.expectMessage(
- "For search 'child', import field 'my_attribute_and_index': " +
+ "For schema 'child', import field 'my_attribute_and_index': " +
"Field 'attribute_and_index' via reference field 'ref': Is an index field. Not supported");
new SearchModel()
.addImportedField("my_attribute_and_index", "ref", "attribute_and_index")
@@ -96,55 +96,54 @@ public class ImportedFieldsResolverTestCase {
public void resolver_fails_if_imported_field_is_of_type_predicate() {
exceptionRule.expect(IllegalArgumentException.class);
exceptionRule.expectMessage(
- "For search 'child', import field 'my_predicate_field': " +
+ "For schema 'child', import field 'my_predicate_field': " +
"Field 'predicate_field' via reference field 'ref': Is of type 'predicate'. Not supported");
new SearchModel().addImportedField("my_predicate_field", "ref", "predicate_field").resolve();
}
static class SearchModel extends ParentChildSearchModel {
- public final Search grandParentSearch;
+ public final Schema grandParentSchema;
public ImportedFields importedFields;
public SearchModel() {
super();
- grandParentSearch = createSearch("grandparent");
- grandParentSearch.getDocument().addField(createField("ancient_field", DataType.INT, "{ attribute }"));
-
- parentSearch.getDocument().addField(createField("attribute_field", DataType.INT, "{ attribute }"));
- parentSearch.getDocument().addField(createField("attribute_and_index", DataType.INT, "{ attribute | index }"));
- parentSearch.getDocument().addField(new TemporarySDField("not_attribute", DataType.INT));
- parentSearch.getDocument().addField(createField("tensor_field", new TensorDataType(TensorType.fromSpec("tensor(x[5])")), "{ attribute }"));
- parentSearch.getDocument().addField(createField("predicate_field", DataType.PREDICATE, "{ attribute }"));
- addRefField(parentSearch, grandParentSearch, "ref");
- addImportedField(parentSearch, "ancient_field", "ref", "ancient_field");
-
- addRefField(childSearch, parentSearch, "ref");
+ grandParentSchema = createSearch("grandparent");
+ grandParentSchema.getDocument().addField(createField("ancient_field", DataType.INT, "{ attribute }"));
+
+ parentSchema.getDocument().addField(createField("attribute_field", DataType.INT, "{ attribute }"));
+ parentSchema.getDocument().addField(createField("attribute_and_index", DataType.INT, "{ attribute | index }"));
+ parentSchema.getDocument().addField(new TemporarySDField("not_attribute", DataType.INT));
+ parentSchema.getDocument().addField(createField("tensor_field", new TensorDataType(TensorType.fromSpec("tensor(x[5])")), "{ attribute }"));
+ parentSchema.getDocument().addField(createField("predicate_field", DataType.PREDICATE, "{ attribute }"));
+ addRefField(parentSchema, grandParentSchema, "ref");
+ addImportedField(parentSchema, "ancient_field", "ref", "ancient_field");
+
+ addRefField(childSchema, parentSchema, "ref");
}
protected SearchModel addImportedField(String fieldName, String referenceFieldName, String targetFieldName) {
- return addImportedField(childSearch, fieldName, referenceFieldName, targetFieldName);
+ return addImportedField(childSchema, fieldName, referenceFieldName, targetFieldName);
}
- protected SearchModel addImportedField(Search search, String fieldName, String referenceFieldName, String targetFieldName) {
- super.addImportedField(search, fieldName, referenceFieldName, targetFieldName);
+ protected SearchModel addImportedField(Schema schema, String fieldName, String referenceFieldName, String targetFieldName) {
+ super.addImportedField(schema, fieldName, referenceFieldName, targetFieldName);
return this;
}
public void resolve() {
- resolve(grandParentSearch);
- resolve(parentSearch);
- importedFields = resolve(childSearch);
+ resolve(grandParentSchema);
+ resolve(parentSchema);
+ importedFields = resolve(childSchema);
}
- private static ImportedFields resolve(Search search) {
- assertNotNull(search.temporaryImportedFields().get());
- assertFalse(search.importedFields().isPresent());
- new ImportedFieldsResolver(search, null, null, null).process(true, false);
- assertFalse(search.temporaryImportedFields().isPresent());
- assertNotNull(search.importedFields().get());
- return search.importedFields().get();
+ private static ImportedFields resolve(Schema schema) {
+ assertNotNull(schema.temporaryImportedFields().get());
+ assertFalse(schema.importedFields().isPresent());
+ new ImportedFieldsResolver(schema, null, null, null).process(true, false);
+ assertNotNull(schema.importedFields().get());
+ return schema.importedFields().get();
}
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsTestCase.java
index 65010d96ec0..37b7ab0955c 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImportedFieldsTestCase.java
@@ -1,7 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.processing;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.SearchBuilder;
import com.yahoo.searchdefinition.derived.AttributeFields;
import com.yahoo.searchdefinition.document.ImportedComplexField;
@@ -24,7 +24,7 @@ public class ImportedFieldsTestCase {
@Test
public void fields_can_be_imported_from_referenced_document_types() throws ParseException {
- Search search = buildAdSearch(joinLines(
+ Schema schema = buildAdSearch(joinLines(
"search ad {",
" document ad {",
" field campaign_ref type reference<campaign> { indexing: attribute }",
@@ -33,9 +33,9 @@ public class ImportedFieldsTestCase {
" import field campaign_ref.budget as my_budget {}",
" import field person_ref.name as my_name {}",
"}"));
- assertEquals(2, search.importedFields().get().fields().size());
- assertSearchContainsImportedField("my_budget", "campaign_ref", "campaign", "budget", search);
- assertSearchContainsImportedField("my_name", "person_ref", "person", "name", search);
+ assertEquals(2, schema.importedFields().get().fields().size());
+ assertSearchContainsImportedField("my_budget", "campaign_ref", "campaign", "budget", schema);
+ assertSearchContainsImportedField("my_name", "person_ref", "person", "name", schema);
}
@Rule
@@ -55,9 +55,9 @@ public class ImportedFieldsTestCase {
@Test
public void fail_duplicate_import() throws ParseException {
exception.expect(IllegalArgumentException.class);
- exception.expectMessage("For search 'ad', import field as 'my_budget': Field already imported");
- Search search = buildAdSearch(joinLines(
- "search ad {",
+ exception.expectMessage("For schema 'ad', import field as 'my_budget': Field already imported");
+ Schema schema = buildAdSearch(joinLines(
+ "schema ad {",
" document ad {",
" field campaign_ref type reference<campaign> { indexing: attribute }",
" }",
@@ -66,14 +66,16 @@ public class ImportedFieldsTestCase {
"}"));
}
- private static Search buildAdSearch(String sdContent) throws ParseException {
+ private static Schema buildAdSearch(String sdContent) throws ParseException {
SearchBuilder builder = new SearchBuilder();
- builder.importString(joinLines("search campaign {",
+ builder.importString(joinLines(
+ "schema campaign {",
" document campaign {",
" field budget type int { indexing: attribute }",
" }",
"}"));
- builder.importString(joinLines("search person {",
+ builder.importString(joinLines(
+ "schema person {",
" document person {",
" field name type string { indexing: attribute }",
" }",
@@ -84,29 +86,29 @@ public class ImportedFieldsTestCase {
}
private static void checkStructImport(AncestorStructSdBuilder parentBuilder) throws ParseException {
- Search search = buildChildSearch(parentBuilder.build(), new ChildStructSdBuilder().build());
- checkImportedStructFields(search, parentBuilder);
+ Schema schema = buildChildSearch(parentBuilder.build(), new ChildStructSdBuilder().build());
+ checkImportedStructFields(schema, parentBuilder);
}
private static void checkNestedStructImport(AncestorStructSdBuilder grandParentBuilder) throws ParseException {
- Search search = buildChildSearch(grandParentBuilder.build(),
- new IntermediateParentStructSdBuilder().build(),
- new ChildStructSdBuilder().build());
- checkImportedStructFields(search, grandParentBuilder);
- }
-
- private static void checkImportedStructFields(Search search, AncestorStructSdBuilder ancestorBuilder) {
- assertEquals(3, search.importedFields().get().fields().size());
- checkImportedField("my_elem_array.name", "parent_ref", "parent", "elem_array.name", search, ancestorBuilder.elem_array_name_attr);
- checkImportedField("my_elem_array.weight", "parent_ref", "parent", "elem_array.weight", search, ancestorBuilder.elem_array_weight_attr);
- checkImportedField("my_elem_map.key", "parent_ref", "parent", "elem_map.key", search, ancestorBuilder.elem_map_key_attr);
- checkImportedField("my_elem_map.value.name", "parent_ref", "parent", "elem_map.value.name", search, ancestorBuilder.elem_map_value_name_attr);
- checkImportedField("my_elem_map.value.weight", "parent_ref", "parent", "elem_map.value.weight", search, ancestorBuilder.elem_map_value_weight_attr);
- checkImportedField("my_str_int_map.key", "parent_ref", "parent", "str_int_map.key", search, ancestorBuilder.str_int_map_key_attr);
- checkImportedField("my_str_int_map.value", "parent_ref", "parent", "str_int_map.value", search, ancestorBuilder.str_int_map_value_attr);
- checkImportedField("my_elem_array", "parent_ref", "parent", "elem_array", search, true);
- checkImportedField("my_elem_map", "parent_ref", "parent", "elem_map", search, true);
- checkImportedField("my_str_int_map", "parent_ref", "parent", "str_int_map", search, true);
+ Schema schema = buildChildSearch(grandParentBuilder.build(),
+ new IntermediateParentStructSdBuilder().build(),
+ new ChildStructSdBuilder().build());
+ checkImportedStructFields(schema, grandParentBuilder);
+ }
+
+ private static void checkImportedStructFields(Schema schema, AncestorStructSdBuilder ancestorBuilder) {
+ assertEquals(3, schema.importedFields().get().fields().size());
+ checkImportedField("my_elem_array.name", "parent_ref", "parent", "elem_array.name", schema, ancestorBuilder.elem_array_name_attr);
+ checkImportedField("my_elem_array.weight", "parent_ref", "parent", "elem_array.weight", schema, ancestorBuilder.elem_array_weight_attr);
+ checkImportedField("my_elem_map.key", "parent_ref", "parent", "elem_map.key", schema, ancestorBuilder.elem_map_key_attr);
+ checkImportedField("my_elem_map.value.name", "parent_ref", "parent", "elem_map.value.name", schema, ancestorBuilder.elem_map_value_name_attr);
+ checkImportedField("my_elem_map.value.weight", "parent_ref", "parent", "elem_map.value.weight", schema, ancestorBuilder.elem_map_value_weight_attr);
+ checkImportedField("my_str_int_map.key", "parent_ref", "parent", "str_int_map.key", schema, ancestorBuilder.str_int_map_key_attr);
+ checkImportedField("my_str_int_map.value", "parent_ref", "parent", "str_int_map.value", schema, ancestorBuilder.str_int_map_value_attr);
+ checkImportedField("my_elem_array", "parent_ref", "parent", "elem_array", schema, true);
+ checkImportedField("my_elem_map", "parent_ref", "parent", "elem_map", schema, true);
+ checkImportedField("my_str_int_map", "parent_ref", "parent", "str_int_map", schema, true);
}
@Test
@@ -126,35 +128,35 @@ public class ImportedFieldsTestCase {
@Test
public void check_illegal_struct_import_missing_array_of_struct_attributes() throws ParseException {
exception.expect(IllegalArgumentException.class);
- exception.expectMessage("For search 'child', import field 'my_elem_array': Field 'elem_array' via reference field 'parent_ref': Is not a struct containing an attribute field.");
+ exception.expectMessage("For schema 'child', import field 'my_elem_array': Field 'elem_array' via reference field 'parent_ref': Is not a struct containing an attribute field.");
checkStructImport(new ParentStructSdBuilder().elem_array_name_attr(false).elem_array_weight_attr(false));
}
@Test
public void check_illegal_struct_import_missing_map_of_struct_key_attribute() throws ParseException {
exception.expect(IllegalArgumentException.class);
- exception.expectMessage("For search 'child', import field 'my_elem_map' (nested to 'my_elem_map.key'): Field 'elem_map.key' via reference field 'parent_ref': Is not an attribute field. Only attribute fields supported");
+ exception.expectMessage("For schema 'child', import field 'my_elem_map' (nested to 'my_elem_map.key'): Field 'elem_map.key' via reference field 'parent_ref': Is not an attribute field. Only attribute fields supported");
checkStructImport(new ParentStructSdBuilder().elem_map_key_attr(false));
}
@Test
public void check_illegal_struct_import_missing_map_of_struct_value_attributes() throws ParseException {
exception.expect(IllegalArgumentException.class);
- exception.expectMessage("For search 'child', import field 'my_elem_map' (nested to 'my_elem_map.value'): Field 'elem_map.value' via reference field 'parent_ref': Is not a struct containing an attribute field.");
+ exception.expectMessage("For schema 'child', import field 'my_elem_map' (nested to 'my_elem_map.value'): Field 'elem_map.value' via reference field 'parent_ref': Is not a struct containing an attribute field.");
checkStructImport(new ParentStructSdBuilder().elem_map_value_name_attr(false).elem_map_value_weight_attr(false));
}
@Test
public void check_illegal_struct_import_missing_map_of_primitive_key_attribute() throws ParseException {
exception.expect(IllegalArgumentException.class);
- exception.expectMessage("For search 'child', import field 'my_str_int_map' (nested to 'my_str_int_map.key'): Field 'str_int_map.key' via reference field 'parent_ref': Is not an attribute field. Only attribute fields supported");
+ exception.expectMessage("For schema 'child', import field 'my_str_int_map' (nested to 'my_str_int_map.key'): Field 'str_int_map.key' via reference field 'parent_ref': Is not an attribute field. Only attribute fields supported");
checkStructImport(new ParentStructSdBuilder().str_int_map_key_attr(false));
}
@Test
public void check_illegal_struct_import_missing_map_of_primitive_value_attribute() throws ParseException {
exception.expect(IllegalArgumentException.class);
- exception.expectMessage("For search 'child', import field 'my_str_int_map' (nested to 'my_str_int_map.value'): Field 'str_int_map.value' via reference field 'parent_ref': Is not an attribute field. Only attribute fields supported");
+ exception.expectMessage("For schema 'child', import field 'my_str_int_map' (nested to 'my_str_int_map.value'): Field 'str_int_map.value' via reference field 'parent_ref': Is not an attribute field. Only attribute fields supported");
checkStructImport(new ParentStructSdBuilder().str_int_map_value_attr(false));
}
@@ -308,7 +310,7 @@ public class ImportedFieldsTestCase {
}
}
- private static Search buildChildSearch(String parentSdContent, String sdContent) throws ParseException {
+ private static Schema buildChildSearch(String parentSdContent, String sdContent) throws ParseException {
SearchBuilder builder = new SearchBuilder();
builder.importString(parentSdContent);
builder.importString(sdContent);
@@ -316,7 +318,7 @@ public class ImportedFieldsTestCase {
return builder.getSearch("child");
}
- private static Search buildChildSearch(String grandParentSdContent, String parentSdContent, String sdContent) throws ParseException {
+ private static Schema buildChildSearch(String grandParentSdContent, String parentSdContent, String sdContent) throws ParseException {
SearchBuilder builder = new SearchBuilder();
builder.importString(grandParentSdContent);
builder.importString(parentSdContent);
@@ -389,19 +391,19 @@ public class ImportedFieldsTestCase {
}
private static void checkPosImport(ParentPosSdBuilder parentBuilder, DescendantPosSdBuilder childBuilder) throws ParseException {
- Search search = buildChildSearch(parentBuilder.build(), childBuilder.build());
- checkImportedPosFields(search);
+ Schema schema = buildChildSearch(parentBuilder.build(), childBuilder.build());
+ checkImportedPosFields(schema);
}
private static void checkNestedPosImport(GrandParentPosSdBuilder grandParentBuilder, DescendantPosSdBuilder childBuilder) throws ParseException {
- Search search = buildChildSearch(grandParentBuilder.build(), new IntermediateParentPosSdBuilder().build(), childBuilder.build());
- checkImportedPosFields(search);
+ Schema schema = buildChildSearch(grandParentBuilder.build(), new IntermediateParentPosSdBuilder().build(), childBuilder.build());
+ checkImportedPosFields(schema);
}
- private static void checkImportedPosFields(Search search) {
- assertEquals(2, search.importedFields().get().fields().size());
- assertSearchContainsImportedField("my_pos_zcurve", "parent_ref", "parent", "pos_zcurve", search);
- assertSearchContainsImportedField("my_pos", "parent_ref", "parent", "pos", search);
+ private static void checkImportedPosFields(Schema schema) {
+ assertEquals(2, schema.importedFields().get().fields().size());
+ assertSearchContainsImportedField("my_pos_zcurve", "parent_ref", "parent", "pos_zcurve", schema);
+ assertSearchContainsImportedField("my_pos", "parent_ref", "parent", "pos", schema);
}
@Test
@@ -417,26 +419,26 @@ public class ImportedFieldsTestCase {
@Test
public void check_pos_import_after_pos_zcurve_import() throws ParseException {
exception.expect(IllegalArgumentException.class);
- exception.expectMessage("For search 'child', import field 'my_pos_zcurve': Field 'pos_zcurve' via reference field 'parent_ref': Field already imported");
+ exception.expectMessage("For schema 'child', import field 'my_pos_zcurve': Field 'pos_zcurve' via reference field 'parent_ref': Field already imported");
checkPosImport(new ParentPosSdBuilder(), new ChildPosSdBuilder().import_pos_zcurve_before(true));
}
- private static ImportedField getImportedField(String name, Search search) {
+ private static ImportedField getImportedField(String name, Schema schema) {
if (name.contains(".")) {
- assertNull(search.importedFields().get().fields().get(name));
+ assertNull(schema.importedFields().get().fields().get(name));
String superFieldName = name.substring(0,name.indexOf("."));
String subFieldName = name.substring(name.indexOf(".")+1);
- ImportedField superField = search.importedFields().get().fields().get(superFieldName);
+ ImportedField superField = schema.importedFields().get().fields().get(superFieldName);
if (superField != null && superField instanceof ImportedComplexField) {
return ((ImportedComplexField)superField).getNestedField(subFieldName);
}
return null;
}
- return search.importedFields().get().fields().get(name);
+ return schema.importedFields().get().fields().get(name);
}
- private static void assertSearchNotContainsImportedField(String fieldName, Search search) {
- ImportedField importedField = getImportedField(fieldName, search);
+ private static void assertSearchNotContainsImportedField(String fieldName, Schema schema) {
+ ImportedField importedField = getImportedField(fieldName, schema);
assertNull(importedField);
}
@@ -444,8 +446,8 @@ public class ImportedFieldsTestCase {
String referenceFieldName,
String referenceDocType,
String targetFieldName,
- Search search) {
- ImportedField importedField = getImportedField(fieldName, search);
+ Schema schema) {
+ ImportedField importedField = getImportedField(fieldName, schema);
assertNotNull(importedField);
assertEquals(fieldName, importedField.fieldName());
assertEquals(referenceFieldName, importedField.reference().referenceField().getName());
@@ -454,11 +456,11 @@ public class ImportedFieldsTestCase {
}
private static void checkImportedField(String fieldName, String referenceFieldName, String referenceDocType,
- String targetFieldName, Search search, boolean present) {
+ String targetFieldName, Schema schema, boolean present) {
if (present) {
- assertSearchContainsImportedField(fieldName, referenceFieldName, referenceDocType, targetFieldName, search);
+ assertSearchContainsImportedField(fieldName, referenceFieldName, referenceDocType, targetFieldName, schema);
} else {
- assertSearchNotContainsImportedField(fieldName, search);
+ assertSearchNotContainsImportedField(fieldName, schema);
}
}
@@ -479,7 +481,7 @@ public class ImportedFieldsTestCase {
checkImportedField("entries_from_b.value", "ref_parent_b", "parent_b", "entries.value", child, true);
}
- private void assertParentContainsEntriesAttributes(Search parent) {
+ private void assertParentContainsEntriesAttributes(Schema parent) {
var attrs = new AttributeFields(parent);
assertTrue(attrs.containsAttribute("entries.key"));
assertTrue(attrs.containsAttribute("entries.value"));
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingInputsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingInputsTestCase.java
index bb935fb8a90..725b1b17ff0 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingInputsTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingInputsTestCase.java
@@ -16,7 +16,7 @@ public class IndexingInputsTestCase {
@Test
public void requireThatExtraFieldInputExtraFieldThrows() throws IOException, ParseException {
assertBuildFails("src/test/examples/indexing_extra_field_input_extra_field.sd",
- "For search 'indexing_extra_field_input_extra_field', field 'bar': Indexing script refers " +
+ "For schema 'indexing_extra_field_input_extra_field', field 'bar': Indexing script refers " +
"to field 'bar' which does not exist in document type " +
"'indexing_extra_field_input_extra_field', and is not a mutable attribute.");
}
@@ -24,21 +24,22 @@ public class IndexingInputsTestCase {
@Test
public void requireThatExtraFieldInputImplicitThrows() throws IOException, ParseException {
assertBuildFails("src/test/examples/indexing_extra_field_input_implicit.sd",
- "For search 'indexing_extra_field_input_implicit', field 'foo': Indexing script refers to " +
+ "For schema 'indexing_extra_field_input_implicit', field 'foo': Indexing script refers to " +
"field 'foo' which does not exist in document type 'indexing_extra_field_input_implicit', and is not a mutable attribute.");
}
@Test
public void requireThatExtraFieldInputNullThrows() throws IOException, ParseException {
assertBuildFails("src/test/examples/indexing_extra_field_input_null.sd",
- "For search 'indexing_extra_field_input_null', field 'foo': Indexing script refers to field " +
+ "For schema 'indexing_extra_field_input_null', field 'foo': Indexing script refers to field " +
"'foo' which does not exist in document type 'indexing_extra_field_input_null', and is not a mutable attribute.");
}
@Test
public void requireThatExtraFieldInputSelfThrows() throws IOException, ParseException {
assertBuildFails("src/test/examples/indexing_extra_field_input_self.sd",
- "For search 'indexing_extra_field_input_self', field 'foo': Indexing script refers to field " +
+ "For schema 'indexing_extra_field_input_self', field 'foo': Indexing script refers to field " +
"'foo' which does not exist in document type 'indexing_extra_field_input_self', and is not a mutable attribute.");
}
+
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingOutputsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingOutputsTestCase.java
index 4d765127276..5ea4b37991a 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingOutputsTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingOutputsTestCase.java
@@ -17,14 +17,14 @@ public class IndexingOutputsTestCase {
@Test
public void requireThatOutputOtherFieldThrows() throws IOException, ParseException {
assertBuildFails("src/test/examples/indexing_output_other_field.sd",
- "For search 'indexing_output_other_field', field 'foo': Indexing expression 'index bar' " +
+ "For schema 'indexing_output_other_field', field 'foo': Indexing expression 'index bar' " +
"attempts to write to a field other than 'foo'.");
}
@Test
public void requireThatOutputConflictThrows() throws IOException, ParseException {
assertBuildFails("src/test/examples/indexing_output_conflict.sd",
- "For search 'indexing_output_confict', field 'bar': For expression 'index bar': Attempting " +
+ "For schema 'indexing_output_confict', field 'bar': For expression 'index bar': Attempting " +
"to assign conflicting values to field 'bar'.");
}
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingScriptRewriterTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingScriptRewriterTestCase.java
index 13581a1e9e6..9cbecddfffa 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingScriptRewriterTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingScriptRewriterTestCase.java
@@ -5,9 +5,9 @@ import com.yahoo.config.model.application.provider.BaseDeployLogger;
import com.yahoo.document.DataType;
import com.yahoo.searchdefinition.Index;
import com.yahoo.searchdefinition.RankProfileRegistry;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.SearchBuilder;
-import com.yahoo.searchdefinition.SchemaTestCase;
+import com.yahoo.searchdefinition.AbstractSchemaTestCase;
import com.yahoo.searchdefinition.document.BooleanIndexDefinition;
import com.yahoo.searchdefinition.document.SDDocumentType;
import com.yahoo.searchdefinition.document.SDField;
@@ -21,6 +21,7 @@ import java.util.Arrays;
import java.util.OptionalDouble;
import java.util.OptionalInt;
import java.util.OptionalLong;
+import java.util.Set;
import static com.yahoo.searchdefinition.processing.AssertIndexingScript.assertIndexing;
import static org.junit.Assert.assertEquals;
@@ -28,7 +29,7 @@ import static org.junit.Assert.assertEquals;
/**
* @author Simon Thoresen Hult
*/
-public class IndexingScriptRewriterTestCase extends SchemaTestCase {
+public class IndexingScriptRewriterTestCase extends AbstractSchemaTestCase {
@Test
public void testSetLanguageRewriting() {
@@ -153,9 +154,10 @@ public class IndexingScriptRewriterTestCase extends SchemaTestCase {
private static ScriptExpression processField(SDField unprocessedField) {
SDDocumentType sdoc = new SDDocumentType("test");
sdoc.addField(unprocessedField);
- Search search = new Search("test");
- search.addDocument(sdoc);
- new Processing().process(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles(), true, false);
+ Schema schema = new Schema("test");
+ schema.addDocument(sdoc);
+ new Processing().process(schema, new BaseDeployLogger(), new RankProfileRegistry(),
+ new QueryProfiles(), true, false, Set.of());
return unprocessedField.getIndexingScript();
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingValidationTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingValidationTestCase.java
index 15f2b179470..9f8e810f1f8 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingValidationTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingValidationTestCase.java
@@ -20,42 +20,42 @@ public class IndexingValidationTestCase extends AbstractExportingTestCase {
@Test
public void testAttributeChanged() throws IOException, ParseException {
assertBuildFails("src/test/examples/indexing_attribute_changed.sd",
- "For search 'indexing_attribute_changed', field 'foo': For expression 'attribute foo': " +
+ "For schema 'indexing_attribute_changed', field 'foo': For expression 'attribute foo': " +
"Attempting to assign conflicting values to field 'foo'.");
}
@Test
public void testAttributeOther() throws IOException, ParseException {
assertBuildFails("src/test/examples/indexing_attribute_other.sd",
- "For search 'indexing_attribute_other', field 'foo': Indexing expression 'attribute bar' " +
+ "For schema 'indexing_attribute_other', field 'foo': Indexing expression 'attribute bar' " +
"attempts to write to a field other than 'foo'.");
}
@Test
public void testIndexChanged() throws IOException, ParseException {
assertBuildFails("src/test/examples/indexing_index_changed.sd",
- "For search 'indexing_index_changed', field 'foo': For expression 'index foo': " +
+ "For schema 'indexing_index_changed', field 'foo': For expression 'index foo': " +
"Attempting to assign conflicting values to field 'foo'.");
}
@Test
public void testIndexOther() throws IOException, ParseException {
assertBuildFails("src/test/examples/indexing_index_other.sd",
- "For search 'indexing_index_other', field 'foo': Indexing expression 'index bar' " +
+ "For schema 'indexing_index_other', field 'foo': Indexing expression 'index bar' " +
"attempts to write to a field other than 'foo'.");
}
@Test
public void testSummaryChanged() throws IOException, ParseException {
assertBuildFails("src/test/examples/indexing_summary_changed.sd",
- "For search 'indexing_summary_fail', field 'foo': For expression 'summary foo': Attempting " +
+ "For schema 'indexing_summary_fail', field 'foo': For expression 'summary foo': Attempting " +
"to assign conflicting values to field 'foo'.");
}
@Test
public void testSummaryOther() throws IOException, ParseException {
assertBuildFails("src/test/examples/indexing_summary_other.sd",
- "For search 'indexing_summary_other', field 'foo': Indexing expression 'summary bar' " +
+ "For schema 'indexing_summary_other', field 'foo': Indexing expression 'summary bar' " +
"attempts to write to a field other than 'foo'.");
}
@@ -70,7 +70,7 @@ public class IndexingValidationTestCase extends AbstractExportingTestCase {
@Test
public void requireThatMultilineOutputConflictThrows() throws IOException, ParseException {
assertBuildFails("src/test/examples/indexing_multiline_output_conflict.sd",
- "For search 'indexing_multiline_output_confict', field 'cox': For expression 'index cox': " +
+ "For schema 'indexing_multiline_output_confict', field 'cox': For expression 'index cox': " +
"Attempting to assign conflicting values to field 'cox'.");
}
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingValuesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingValuesTestCase.java
index 64089f6f5fa..25d966b1324 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingValuesTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IndexingValuesTestCase.java
@@ -22,7 +22,7 @@ public class IndexingValuesTestCase {
@Test
public void requireThatInputOtherFieldThrows() throws IOException, ParseException {
assertBuildFails("src/test/examples/indexing_input_other_field.sd",
- "For search 'indexing_input_other_field', field 'bar': Indexing expression 'input foo' " +
+ "For schema 'indexing_input_other_field', field 'bar': Indexing expression 'input foo' " +
"attempts to modify the value of the document field 'bar'. " +
"Use a field outside the document block instead.");
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IntegerIndex2AttributeTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IntegerIndex2AttributeTestCase.java
index 91f719c4eb8..cd5dd451026 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/IntegerIndex2AttributeTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/IntegerIndex2AttributeTestCase.java
@@ -3,9 +3,9 @@ package com.yahoo.searchdefinition.processing;
import com.yahoo.config.model.application.provider.BaseDeployLogger;
import com.yahoo.searchdefinition.RankProfileRegistry;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.SearchBuilder;
-import com.yahoo.searchdefinition.SchemaTestCase;
+import com.yahoo.searchdefinition.AbstractSchemaTestCase;
import com.yahoo.searchdefinition.document.SDField;
import com.yahoo.searchdefinition.parser.ParseException;
import com.yahoo.vespa.model.container.search.QueryProfiles;
@@ -20,40 +20,40 @@ import static org.junit.Assert.assertTrue;
/**
* @author baldersheim
*/
-public class IntegerIndex2AttributeTestCase extends SchemaTestCase {
+public class IntegerIndex2AttributeTestCase extends AbstractSchemaTestCase {
@Test
public void testIntegerIndex2Attribute() throws IOException, ParseException {
- Search search = SearchBuilder.buildFromFile("src/test/examples/integerindex2attribute.sd");
- new IntegerIndex2Attribute(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles()).process(true, false);
+ Schema schema = SearchBuilder.buildFromFile("src/test/examples/integerindex2attribute.sd");
+ new IntegerIndex2Attribute(schema, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles()).process(true, false);
SDField f;
- f = search.getConcreteField("s1");
+ f = schema.getConcreteField("s1");
assertTrue(f.getAttributes().isEmpty());
assertTrue(f.existsIndex("s1"));
- f = search.getConcreteField("s2");
+ f = schema.getConcreteField("s2");
assertEquals(f.getAttributes().size(), 1);
assertTrue(f.existsIndex("s2"));
- f = search.getConcreteField("as1");
+ f = schema.getConcreteField("as1");
assertTrue(f.getAttributes().isEmpty());
assertTrue(f.existsIndex("as1"));
- f = search.getConcreteField("as2");
+ f = schema.getConcreteField("as2");
assertEquals(f.getAttributes().size(), 1);
assertTrue(f.existsIndex("as2"));
- f = search.getConcreteField("i1");
+ f = schema.getConcreteField("i1");
assertEquals(f.getAttributes().size(), 1);
assertFalse(f.existsIndex("i1"));
- f = search.getConcreteField("i2");
+ f = schema.getConcreteField("i2");
assertEquals(f.getAttributes().size(), 1);
assertFalse(f.existsIndex("i2"));
- f = search.getConcreteField("ai1");
- assertEquals(search.getConcreteField("ai1").getAttributes().size(), 1);
- assertFalse(search.getConcreteField("ai1").existsIndex("ai1"));
- f = search.getConcreteField("ai2");
+ f = schema.getConcreteField("ai1");
+ assertEquals(schema.getConcreteField("ai1").getAttributes().size(), 1);
+ assertFalse(schema.getConcreteField("ai1").existsIndex("ai1"));
+ f = schema.getConcreteField("ai2");
assertEquals(f.getAttributes().size(), 1);
assertFalse(f.existsIndex("ai2"));
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java
index ab98706fd44..fc44d61541e 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolverTestCase.java
@@ -2,7 +2,7 @@
package com.yahoo.searchdefinition.processing;
import com.yahoo.searchdefinition.RankProfileRegistry;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.SearchBuilder;
import com.yahoo.searchdefinition.parser.ParseException;
import com.yahoo.vespa.documentmodel.SummaryField;
@@ -134,7 +134,8 @@ public class MatchedElementsOnlyResolverTestCase {
" }",
"}");
- var search = buildSearch(joinLines("field my_field type array<string> {",
+ var search = buildSearch(joinLines(
+ "field my_field type array<string> {",
" indexing: attribute | summary",
"}"),
documentSummary);
@@ -147,7 +148,7 @@ public class MatchedElementsOnlyResolverTestCase {
@Test
public void unsupported_field_type_throws() throws ParseException {
exceptionRule.expect(IllegalArgumentException.class);
- exceptionRule.expectMessage("For search 'test', document summary 'default', summary field 'my_field': " +
+ exceptionRule.expectMessage("For schema 'test', document summary 'default', summary field 'my_field': " +
"'matched-elements-only' is not supported for this field type. " +
"Supported field types are: array of primitive, weighted set of primitive, " +
"array of simple struct, map of primitive type to simple struct, " +
@@ -168,11 +169,11 @@ public class MatchedElementsOnlyResolverTestCase {
assertEquals(expSourceField, field.getSingleSource());
}
- private Search buildSearch(String field) throws ParseException {
+ private Schema buildSearch(String field) throws ParseException {
return buildSearch(field, "");
}
- private Search buildSearch(String field, String summary) throws ParseException {
+ private Schema buildSearch(String field, String summary) throws ParseException {
var builder = new SearchBuilder(new RankProfileRegistry());
builder.importString(joinLines("search test {",
" document test {",
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/NGramTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/NGramTestCase.java
index 8d8a19796ba..0e13aacb76f 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/NGramTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/NGramTestCase.java
@@ -1,9 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.processing;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.SearchBuilder;
-import com.yahoo.searchdefinition.SchemaTestCase;
+import com.yahoo.searchdefinition.AbstractSchemaTestCase;
import com.yahoo.searchdefinition.document.Matching;
import com.yahoo.searchdefinition.document.SDField;
import com.yahoo.searchdefinition.document.Stemming;
@@ -21,22 +21,22 @@ import static org.junit.Assert.fail;
/**
* @author bratseth
*/
-public class NGramTestCase extends SchemaTestCase {
+public class NGramTestCase extends AbstractSchemaTestCase {
@Test
public void testNGram() throws IOException, ParseException {
- Search search = SearchBuilder.buildFromFile("src/test/examples/ngram.sd");
- assertNotNull(search);
+ Schema schema = SearchBuilder.buildFromFile("src/test/examples/ngram.sd");
+ assertNotNull(schema);
- SDField gram1 = search.getConcreteField("gram_1");
+ SDField gram1 = schema.getConcreteField("gram_1");
assertEquals(Matching.Type.GRAM, gram1.getMatching().getType());
assertEquals(1, gram1.getMatching().getGramSize());
- SDField gram2 = search.getConcreteField("gram_2");
+ SDField gram2 = schema.getConcreteField("gram_2");
assertEquals(Matching.Type.GRAM, gram2.getMatching().getType());
assertEquals(-1, gram2.getMatching().getGramSize()); // Not set explicitly
- SDField gram3=search.getConcreteField("gram_3");
+ SDField gram3= schema.getConcreteField("gram_3");
assertEquals(Matching.Type.GRAM,gram3.getMatching().getType());
assertEquals(3, gram3.getMatching().getGramSize());
@@ -55,7 +55,7 @@ public class NGramTestCase extends SchemaTestCase {
@Test
public void testInvalidNGramSetting1() throws IOException, ParseException {
try {
- Search search = SearchBuilder.buildFromFile("src/test/examples/invalidngram1.sd");
+ Schema schema = SearchBuilder.buildFromFile("src/test/examples/invalidngram1.sd");
fail("Should cause an exception");
}
catch (IllegalArgumentException e) {
@@ -66,7 +66,7 @@ public class NGramTestCase extends SchemaTestCase {
@Test
public void testInvalidNGramSetting2() throws IOException, ParseException {
try {
- Search search = SearchBuilder.buildFromFile("src/test/examples/invalidngram2.sd");
+ Schema schema = SearchBuilder.buildFromFile("src/test/examples/invalidngram2.sd");
fail("Should cause an exception");
}
catch (IllegalArgumentException e) {
@@ -77,7 +77,7 @@ public class NGramTestCase extends SchemaTestCase {
@Test
public void testInvalidNGramSetting3() throws IOException, ParseException {
try {
- Search search = SearchBuilder.buildFromFile("src/test/examples/invalidngram3.sd");
+ Schema schema = SearchBuilder.buildFromFile("src/test/examples/invalidngram3.sd");
fail("Should cause an exception");
}
catch (IllegalArgumentException e) {
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/PagedAttributeValidatorTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/PagedAttributeValidatorTestCase.java
index 038bfc9ddbf..360072c1da7 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/PagedAttributeValidatorTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/PagedAttributeValidatorTestCase.java
@@ -31,13 +31,14 @@ public class PagedAttributeValidatorTestCase {
createFromString(getSd(fieldType));
fail("Expected exception");
} catch (IllegalArgumentException e) {
- assertEquals("For search 'test', field 'foo': The 'paged' attribute setting is only supported for dense tensor types",
+ assertEquals("For schema 'test', field 'foo': The 'paged' attribute setting is only supported for dense tensor types",
e.getMessage());
}
}
private String getSd(String type) {
- return joinLines("search test {",
+ return joinLines(
+ "schema test {",
" document test {",
" field foo type " + type + "{",
" indexing: attribute",
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ParentChildSearchModel.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ParentChildSearchModel.java
index 6366be84d8e..a01fdd8725d 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ParentChildSearchModel.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ParentChildSearchModel.java
@@ -2,16 +2,16 @@
package com.yahoo.searchdefinition.processing;
import com.google.common.collect.ImmutableMap;
-import com.yahoo.config.application.api.ApplicationPackage;
import com.yahoo.config.model.application.provider.MockFileRegistry;
import com.yahoo.config.model.deploy.TestProperties;
import com.yahoo.config.model.test.MockApplicationPackage;
import com.yahoo.document.DataType;
import com.yahoo.document.ReferenceDataType;
import com.yahoo.document.TemporaryStructuredDataType;
+import com.yahoo.searchdefinition.Application;
import com.yahoo.searchdefinition.DocumentReference;
import com.yahoo.searchdefinition.DocumentReferences;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.derived.TestableDeployLogger;
import com.yahoo.searchdefinition.document.SDDocumentType;
import com.yahoo.searchdefinition.document.SDField;
@@ -22,17 +22,18 @@ import com.yahoo.searchdefinition.document.TemporarySDField;
* Fixture class used for ImportedFieldsResolverTestCase and AdjustPositionSummaryFieldsTestCase.
*/
public class ParentChildSearchModel {
- private final ApplicationPackage app = MockApplicationPackage.createEmpty();
- public Search parentSearch;
- public Search childSearch;
+
+ private final Application application = new Application(MockApplicationPackage.createEmpty());
+ public Schema parentSchema;
+ public Schema childSchema;
ParentChildSearchModel() {
- parentSearch = createSearch("parent");
- childSearch = createSearch("child");
+ parentSchema = createSearch("parent");
+ childSchema = createSearch("child");
}
- protected Search createSearch(String name) {
- Search result = new Search(name, app, new MockFileRegistry(), new TestableDeployLogger(), new TestProperties());
+ protected Schema createSearch(String name) {
+ Schema result = new Schema(name, application, new MockFileRegistry(), new TestableDeployLogger(), new TestProperties());
result.addDocument(new SDDocumentType(name));
return result;
}
@@ -47,7 +48,7 @@ public class ParentChildSearchModel {
return new TemporarySDField(fieldName, ReferenceDataType.createWithInferredId(TemporaryStructuredDataType.create(parentType)));
}
- protected static void addRefField(Search child, Search parent, String fieldName) {
+ protected static void addRefField(Schema child, Schema parent, String fieldName) {
SDField refField = createRefField(parent.getName(), fieldName);
child.getDocument().addField(refField);
child.getDocument().setDocumentReferences(new DocumentReferences(ImmutableMap.of(refField.getName(),
@@ -55,11 +56,11 @@ public class ParentChildSearchModel {
}
protected ParentChildSearchModel addImportedField(String fieldName, String referenceFieldName, String targetFieldName) {
- return addImportedField(childSearch, fieldName, referenceFieldName, targetFieldName);
+ return addImportedField(childSchema, fieldName, referenceFieldName, targetFieldName);
}
- protected ParentChildSearchModel addImportedField(Search search, String fieldName, String referenceFieldName, String targetFieldName) {
- search.temporaryImportedFields().get().add(new TemporaryImportedField(fieldName, referenceFieldName, targetFieldName));
+ protected ParentChildSearchModel addImportedField(Schema schema, String fieldName, String referenceFieldName, String targetFieldName) {
+ schema.temporaryImportedFields().get().add(new TemporaryImportedField(fieldName, referenceFieldName, targetFieldName));
return this;
}
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/PositionTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/PositionTestCase.java
index bcec2bfacfa..67e47b7f2ae 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/PositionTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/PositionTestCase.java
@@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.processing;
import com.yahoo.document.DataType;
import com.yahoo.document.DocumentType;
import com.yahoo.document.PositionDataType;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.SearchBuilder;
import com.yahoo.searchdefinition.document.Attribute;
import com.yahoo.searchdefinition.document.FieldSet;
@@ -31,20 +31,20 @@ public class PositionTestCase {
"src/test/examples/position_base.sd",
"src/test/examples/position_inherited.sd"));
- Search search = sb.getSearch("position_inherited");
- FieldSet fieldSet = search.getDocument().getFieldSets().builtInFieldSets().get(DocumentType.DOCUMENT);
+ Schema schema = sb.getSearch("position_inherited");
+ FieldSet fieldSet = schema.getDocument().getFieldSets().builtInFieldSets().get(DocumentType.DOCUMENT);
assertFalse(fieldSet.getFieldNames().contains(PositionDataType.getZCurveFieldName("pos")));
}
@Test
public void requireThatPositionCanBeAttribute() throws Exception {
- Search search = SearchBuilder.buildFromFile("src/test/examples/position_attribute.sd");
- assertNull(search.getAttribute("pos"));
- assertNull(search.getAttribute("pos.x"));
- assertNull(search.getAttribute("pos.y"));
+ Schema schema = SearchBuilder.buildFromFile("src/test/examples/position_attribute.sd");
+ assertNull(schema.getAttribute("pos"));
+ assertNull(schema.getAttribute("pos.x"));
+ assertNull(schema.getAttribute("pos.y"));
- assertPositionAttribute(search, "pos", Attribute.CollectionType.SINGLE);
- assertPositionSummary(search, "pos", false);
+ assertPositionAttribute(schema, "pos", Attribute.CollectionType.SINGLE);
+ assertPositionSummary(schema, "pos", false);
}
@Test
@@ -53,20 +53,20 @@ public class PositionTestCase {
SearchBuilder.buildFromFile("src/test/examples/position_index.sd");
fail();
} catch (IllegalArgumentException e) {
- assertEquals("For search 'position_index', field 'pos': Indexing of data type 'position' is not " +
+ assertEquals("For schema 'position_index', field 'pos': Indexing of data type 'position' is not " +
"supported, replace 'index' statement with 'attribute'.", e.getMessage());
}
}
@Test
public void requireThatSummaryAloneDoesNotCreateZCurve() throws Exception {
- Search search = SearchBuilder.buildFromFile("src/test/examples/position_summary.sd");
- assertNull(search.getAttribute("pos"));
- assertNull(search.getAttribute("pos.x"));
- assertNull(search.getAttribute("pos.y"));
- assertNull(search.getAttribute("pos.zcurve"));
+ Schema schema = SearchBuilder.buildFromFile("src/test/examples/position_summary.sd");
+ assertNull(schema.getAttribute("pos"));
+ assertNull(schema.getAttribute("pos.x"));
+ assertNull(schema.getAttribute("pos.y"));
+ assertNull(schema.getAttribute("pos.zcurve"));
- SummaryField summary = search.getSummaryField("pos");
+ SummaryField summary = schema.getSummaryField("pos");
assertNotNull(summary);
assertEquals(2, summary.getSourceCount());
Iterator<SummaryField.Source> it = summary.getSources().iterator();
@@ -74,61 +74,61 @@ public class PositionTestCase {
assertEquals("pos.y", it.next().getName());
assertEquals(SummaryTransform.NONE, summary.getTransform());
- assertNull(search.getSummaryField("pos_ext.distance"));
+ assertNull(schema.getSummaryField("pos_ext.distance"));
}
@Test
public void requireThatExtraFieldCanBePositionAttribute() throws Exception {
- Search search = SearchBuilder.buildFromFile("src/test/examples/position_extra.sd");
- assertNull(search.getAttribute("pos_ext"));
- assertNull(search.getAttribute("pos_ext.x"));
- assertNull(search.getAttribute("pos_ext.y"));
+ Schema schema = SearchBuilder.buildFromFile("src/test/examples/position_extra.sd");
+ assertNull(schema.getAttribute("pos_ext"));
+ assertNull(schema.getAttribute("pos_ext.x"));
+ assertNull(schema.getAttribute("pos_ext.y"));
- assertPositionAttribute(search, "pos_ext", Attribute.CollectionType.SINGLE);
- assertPositionSummary(search, "pos_ext", false);
+ assertPositionAttribute(schema, "pos_ext", Attribute.CollectionType.SINGLE);
+ assertPositionSummary(schema, "pos_ext", false);
}
@Test
public void requireThatPositionArrayIsSupported() throws Exception {
- Search search = SearchBuilder.buildFromFile("src/test/examples/position_array.sd");
- assertNull(search.getAttribute("pos"));
- assertNull(search.getAttribute("pos.x"));
- assertNull(search.getAttribute("pos.y"));
+ Schema schema = SearchBuilder.buildFromFile("src/test/examples/position_array.sd");
+ assertNull(schema.getAttribute("pos"));
+ assertNull(schema.getAttribute("pos.x"));
+ assertNull(schema.getAttribute("pos.y"));
- assertPositionAttribute(search, "pos", Attribute.CollectionType.ARRAY);
- assertPositionSummary(search, "pos", true);
+ assertPositionAttribute(schema, "pos", Attribute.CollectionType.ARRAY);
+ assertPositionSummary(schema, "pos", true);
}
- private static void assertPositionAttribute(Search search, String fieldName, Attribute.CollectionType type) {
- Attribute attribute = search.getAttribute(PositionDataType.getZCurveFieldName(fieldName));
+ private static void assertPositionAttribute(Schema schema, String fieldName, Attribute.CollectionType type) {
+ Attribute attribute = schema.getAttribute(PositionDataType.getZCurveFieldName(fieldName));
assertNotNull(attribute);
assertTrue(attribute.isPosition());
assertEquals(attribute.getCollectionType(), type);
assertEquals(attribute.getType(), Attribute.Type.LONG);
}
- private static void assertPositionSummary(Search search, String fieldName, boolean isArray) {
- assertSummaryField(search,
+ private static void assertPositionSummary(Schema schema, String fieldName, boolean isArray) {
+ assertSummaryField(schema,
fieldName,
PositionDataType.getZCurveFieldName(fieldName),
(isArray ? DataType.getArray(PositionDataType.INSTANCE) : PositionDataType.INSTANCE),
SummaryTransform.GEOPOS);
- assertSummaryField(search,
+ assertSummaryField(schema,
PositionDataType.getDistanceSummaryFieldName(fieldName),
PositionDataType.getZCurveFieldName(fieldName),
DataType.INT,
SummaryTransform.DISTANCE);
- assertSummaryField(search,
+ assertSummaryField(schema,
PositionDataType.getPositionSummaryFieldName(fieldName),
PositionDataType.getZCurveFieldName(fieldName),
DataType.getArray(DataType.STRING),
SummaryTransform.POSITIONS);
}
- private static void assertSummaryField(Search search, String fieldName, String sourceName, DataType dataType,
+ private static void assertSummaryField(Schema schema, String fieldName, String sourceName, DataType dataType,
SummaryTransform transform)
{
- SummaryField summary = search.getSummaryField(fieldName);
+ SummaryField summary = schema.getSummaryField(fieldName);
assertNotNull(summary);
assertEquals(1, summary.getSourceCount());
assertEquals(sourceName, summary.getSingleSource());
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankModifierTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankModifierTestCase.java
index dc7305f55c3..97eed506c85 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankModifierTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankModifierTestCase.java
@@ -1,9 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.processing;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.SearchBuilder;
-import com.yahoo.searchdefinition.SchemaTestCase;
+import com.yahoo.searchdefinition.AbstractSchemaTestCase;
import com.yahoo.searchdefinition.parser.ParseException;
import org.junit.Test;
@@ -14,9 +14,9 @@ import java.io.IOException;
* @author vegardh
*
*/
-public class RankModifierTestCase extends SchemaTestCase {
+public class RankModifierTestCase extends AbstractSchemaTestCase {
@Test
public void testLiteral() throws IOException, ParseException {
- Search search = SearchBuilder.buildFromFile("src/test/examples/rankmodifier/literal.sd");
+ Schema schema = SearchBuilder.buildFromFile("src/test/examples/rankmodifier/literal.sd");
}
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankProfileSearchFixture.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankProfileSearchFixture.java
index 1b8160e0123..7ffb20859e9 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankProfileSearchFixture.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankProfileSearchFixture.java
@@ -12,7 +12,7 @@ import com.yahoo.path.Path;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.searchdefinition.RankProfile;
import com.yahoo.searchdefinition.RankProfileRegistry;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.SearchBuilder;
import com.yahoo.searchdefinition.parser.ParseException;
import ai.vespa.rankingexpression.importer.configmodelview.ImportedMlModels;
@@ -43,7 +43,7 @@ class RankProfileSearchFixture {
new XGBoostImporter());
private final RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
private final QueryProfileRegistry queryProfileRegistry;
- private final Search search;
+ private final Schema schema;
private final Map<String, RankProfile> compiledRankProfiles = new HashMap<>();
private final ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
@@ -79,7 +79,7 @@ class RankProfileSearchFixture {
"}";
builder.importString(sdContent);
builder.build();
- search = builder.getSearch();
+ schema = builder.getSearch();
}
public void assertFirstPhaseExpression(String expExpression, String rankProfile) {
@@ -106,7 +106,7 @@ class RankProfileSearchFixture {
}
public RankProfile compileRankProfile(String rankProfile, Path applicationDir) {
- RankProfile compiled = rankProfileRegistry.get(search, rankProfile)
+ RankProfile compiled = rankProfileRegistry.get(schema, rankProfile)
.compile(queryProfileRegistry,
new ImportedMlModels(applicationDir.toFile(), executor, importers));
compiledRankProfiles.put(rankProfile, compiled);
@@ -115,7 +115,7 @@ class RankProfileSearchFixture {
/** Returns the given uncompiled profile */
public RankProfile rankProfile(String rankProfile) {
- return rankProfileRegistry.get(search, rankProfile);
+ return rankProfileRegistry.get(schema, rankProfile);
}
/** Returns the given compiled profile, or null if not compiled yet or not present at all */
@@ -123,6 +123,6 @@ class RankProfileSearchFixture {
return compiledRankProfiles.get(rankProfile);
}
- public Search search() { return search; }
+ public Schema search() { return schema; }
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankPropertyVariablesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankPropertyVariablesTestCase.java
index 407a5877976..5c53dbf0c57 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankPropertyVariablesTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankPropertyVariablesTestCase.java
@@ -5,9 +5,9 @@ import com.yahoo.config.model.application.provider.BaseDeployLogger;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.searchdefinition.RankProfile.RankProperty;
import com.yahoo.searchdefinition.RankProfileRegistry;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.SearchBuilder;
-import com.yahoo.searchdefinition.SchemaTestCase;
+import com.yahoo.searchdefinition.AbstractSchemaTestCase;
import com.yahoo.searchdefinition.parser.ParseException;
import org.junit.Test;
@@ -16,21 +16,21 @@ import java.util.List;
import static org.junit.Assert.fail;
-public class RankPropertyVariablesTestCase extends SchemaTestCase {
+public class RankPropertyVariablesTestCase extends AbstractSchemaTestCase {
@Test
public void testRankPropVariables() throws IOException, ParseException {
RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
- Search search = SearchBuilder.buildFromFile("src/test/examples/rankpropvars.sd",
+ Schema schema = SearchBuilder.buildFromFile("src/test/examples/rankpropvars.sd",
new BaseDeployLogger(),
rankProfileRegistry,
new QueryProfileRegistry());
- assertRankPropEquals(rankProfileRegistry.get(search, "other").getRankProperties(), "$testvar1", "foo");
- assertRankPropEquals(rankProfileRegistry.get(search, "other").getRankProperties(), "$testvar_2", "bar");
- assertRankPropEquals(rankProfileRegistry.get(search, "other").getRankProperties(), "$testvarOne23", "baz");
- assertRankPropEquals(rankProfileRegistry.get(search, "another").getRankProperties(), "$Testvar1", "1");
- assertRankPropEquals(rankProfileRegistry.get(search, "another").getRankProperties(), "$Testvar_4", "4");
- assertRankPropEquals(rankProfileRegistry.get(search, "another").getRankProperties(), "$testvarFour23", "234234.234");
+ assertRankPropEquals(rankProfileRegistry.get(schema, "other").getRankProperties(), "$testvar1", "foo");
+ assertRankPropEquals(rankProfileRegistry.get(schema, "other").getRankProperties(), "$testvar_2", "bar");
+ assertRankPropEquals(rankProfileRegistry.get(schema, "other").getRankProperties(), "$testvarOne23", "baz");
+ assertRankPropEquals(rankProfileRegistry.get(schema, "another").getRankProperties(), "$Testvar1", "1");
+ assertRankPropEquals(rankProfileRegistry.get(schema, "another").getRankProperties(), "$Testvar_4", "4");
+ assertRankPropEquals(rankProfileRegistry.get(schema, "another").getRankProperties(), "$testvarFour23", "234234.234");
}
private void assertRankPropEquals(List<RankProperty> props, String key, String val) {
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTransformerTokensTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTransformerTokensTestCase.java
index dcd7e2426c3..e77787e22ca 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTransformerTokensTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionWithTransformerTokensTestCase.java
@@ -8,7 +8,7 @@ import com.yahoo.config.model.test.MockApplicationPackage;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.searchdefinition.RankProfile;
import com.yahoo.searchdefinition.RankProfileRegistry;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.SearchBuilder;
import com.yahoo.searchdefinition.expressiontransforms.RankProfileTransformContext;
import com.yahoo.searchdefinition.expressiontransforms.TokenTransformer;
@@ -90,8 +90,8 @@ public class RankingExpressionWithTransformerTokensTestCase {
SearchBuilder searchBuilder = new SearchBuilder(application, new MockFileRegistry(), new BaseDeployLogger(), new TestProperties(), rankProfileRegistry, queryProfileRegistry);
searchBuilder.importString(sdContent);
searchBuilder.build();
- Search search = searchBuilder.getSearch();
- RankProfile rp = rankProfileRegistry.get(search, "my_profile");
+ Schema schema = searchBuilder.getSearch();
+ RankProfile rp = rankProfileRegistry.get(schema, "my_profile");
return new RankProfileTransformContext(rp, queryProfileRegistry, Collections.emptyMap(), null, Collections.emptyMap(), Collections.emptyMap());
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionsTestCase.java
index 27ea680d97a..fc5a2b6a39a 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionsTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionsTestCase.java
@@ -9,8 +9,8 @@ import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.searchdefinition.LargeRankExpressions;
import com.yahoo.searchdefinition.RankProfile;
import com.yahoo.searchdefinition.RankProfileRegistry;
-import com.yahoo.searchdefinition.SchemaTestCase;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
+import com.yahoo.searchdefinition.AbstractSchemaTestCase;
import com.yahoo.searchdefinition.SearchBuilder;
import com.yahoo.searchdefinition.derived.DerivedConfiguration;
import com.yahoo.searchdefinition.derived.AttributeFields;
@@ -28,9 +28,9 @@ import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-public class RankingExpressionsTestCase extends SchemaTestCase {
+public class RankingExpressionsTestCase extends AbstractSchemaTestCase {
- private static Search createSearch(String dir, ModelContext.Properties deployProperties, RankProfileRegistry rankProfileRegistry) throws IOException, ParseException {
+ private static Schema createSearch(String dir, ModelContext.Properties deployProperties, RankProfileRegistry rankProfileRegistry) throws IOException, ParseException {
return SearchBuilder.createFromDirectory(dir, new MockFileRegistry(), new TestableDeployLogger(), deployProperties, rankProfileRegistry).getSearch();
}
@@ -38,8 +38,8 @@ public class RankingExpressionsTestCase extends SchemaTestCase {
public void testFunctions() throws IOException, ParseException {
ModelContext.Properties deployProperties = new TestProperties();
RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
- Search search = createSearch("src/test/examples/rankingexpressionfunction", deployProperties, rankProfileRegistry);
- RankProfile functionsRankProfile = rankProfileRegistry.get(search, "macros");
+ Schema schema = createSearch("src/test/examples/rankingexpressionfunction", deployProperties, rankProfileRegistry);
+ RankProfile functionsRankProfile = rankProfileRegistry.get(schema, "macros");
Map<String, RankProfile.RankingExpressionFunction> functions = functionsRankProfile.getFunctions();
assertEquals(2, functions.get("titlematch$").function().arguments().size());
assertEquals("var1", functions.get("titlematch$").function().arguments().get(0));
@@ -52,7 +52,7 @@ public class RankingExpressionsTestCase extends SchemaTestCase {
assertEquals(0, functions.get("artistmatch").function().arguments().size());
RawRankProfile rawRankProfile = new RawRankProfile(functionsRankProfile, new LargeRankExpressions(new MockFileRegistry()), new QueryProfileRegistry(),
- new ImportedMlModels(), new AttributeFields(search), deployProperties);
+ new ImportedMlModels(), new AttributeFields(schema), deployProperties);
List<Pair<String, String>> rankProperties = rawRankProfile.configProperties();
assertEquals(6, rankProperties.size());
@@ -75,8 +75,8 @@ public class RankingExpressionsTestCase extends SchemaTestCase {
@Test(expected = IllegalArgumentException.class)
public void testThatIncludingFileInSubdirFails() throws IOException, ParseException {
RankProfileRegistry registry = new RankProfileRegistry();
- Search search = createSearch("src/test/examples/rankingexpressioninfile", new TestProperties(), registry);
- new DerivedConfiguration(search, registry); // rank profile parsing happens during deriving
+ Schema schema = createSearch("src/test/examples/rankingexpressioninfile", new TestProperties(), registry);
+ new DerivedConfiguration(schema, registry); // rank profile parsing happens during deriving
}
private void verifyProfile(RankProfile profile, List<String> expectedFunctions, List<Pair<String, String>> rankProperties,
@@ -96,20 +96,20 @@ public class RankingExpressionsTestCase extends SchemaTestCase {
}
}
- private void verifySearch(Search search, RankProfileRegistry rankProfileRegistry, LargeRankExpressions largeExpressions,
+ private void verifySearch(Schema schema, RankProfileRegistry rankProfileRegistry, LargeRankExpressions largeExpressions,
QueryProfileRegistry queryProfiles, ImportedMlModels models, ModelContext.Properties properties)
{
- AttributeFields attributes = new AttributeFields(search);
+ AttributeFields attributes = new AttributeFields(schema);
- verifyProfile(rankProfileRegistry.get(search, "base"), Arrays.asList("large_f", "large_m"),
- Arrays.asList(new Pair<>("rankingExpression(large_f).expressionName", "base.large_f"), new Pair<>("rankingExpression(large_m).expressionName", "base.large_m")),
- largeExpressions, queryProfiles, models, attributes, properties);
+ verifyProfile(rankProfileRegistry.get(schema, "base"), Arrays.asList("large_f", "large_m"),
+ Arrays.asList(new Pair<>("rankingExpression(large_f).expressionName", "base.large_f"), new Pair<>("rankingExpression(large_m).expressionName", "base.large_m")),
+ largeExpressions, queryProfiles, models, attributes, properties);
for (String child : Arrays.asList("child_a", "child_b")) {
- verifyProfile(rankProfileRegistry.get(search, child), Arrays.asList("large_f", "large_m", "large_local_f", "large_local_m"),
- Arrays.asList(new Pair<>("rankingExpression(large_f).expressionName", child + ".large_f"), new Pair<>("rankingExpression(large_m).expressionName", child + ".large_m"),
+ verifyProfile(rankProfileRegistry.get(schema, child), Arrays.asList("large_f", "large_m", "large_local_f", "large_local_m"),
+ Arrays.asList(new Pair<>("rankingExpression(large_f).expressionName", child + ".large_f"), new Pair<>("rankingExpression(large_m).expressionName", child + ".large_m"),
new Pair<>("rankingExpression(large_local_f).expressionName", child + ".large_local_f"), new Pair<>("rankingExpression(large_local_m).expressionName", child + ".large_local_m"),
new Pair<>("vespa.rank.firstphase", "rankingExpression(firstphase)"), new Pair<>("rankingExpression(firstphase).expressionName", child + ".firstphase")),
- largeExpressions, queryProfiles, models, attributes, properties);
+ largeExpressions, queryProfiles, models, attributes, properties);
}
}
@@ -120,9 +120,9 @@ public class RankingExpressionsTestCase extends SchemaTestCase {
LargeRankExpressions largeExpressions = new LargeRankExpressions(new MockFileRegistry());
QueryProfileRegistry queryProfiles = new QueryProfileRegistry();
ImportedMlModels models = new ImportedMlModels();
- Search search = createSearch("src/test/examples/largerankingexpressions", properties, rankProfileRegistry);
- verifySearch(search, rankProfileRegistry, largeExpressions, queryProfiles, models, properties);
+ Schema schema = createSearch("src/test/examples/largerankingexpressions", properties, rankProfileRegistry);
+ verifySearch(schema, rankProfileRegistry, largeExpressions, queryProfiles, models, properties);
// Need to verify that second derivation works as that will happen if same sd is used in multiple content clusters
- verifySearch(search, rankProfileRegistry, largeExpressions, queryProfiles, models, properties);
+ verifySearch(schema, rankProfileRegistry, largeExpressions, queryProfiles, models, properties);
}
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReferenceFieldTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReferenceFieldTestCase.java
index ad38e65e655..41b9d480921 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReferenceFieldTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReferenceFieldTestCase.java
@@ -5,7 +5,7 @@ import com.yahoo.document.DataType;
import com.yahoo.document.Field;
import com.yahoo.document.ReferenceDataType;
import com.yahoo.searchdefinition.DocumentGraphValidator;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.SearchBuilder;
import com.yahoo.searchdefinition.document.SDDocumentType;
import com.yahoo.searchdefinition.parser.ParseException;
@@ -50,9 +50,9 @@ public class ReferenceFieldTestCase {
builder.importString(salespersonSdContent);
builder.importString(adSdContent);
builder.build();
- Search search = builder.getSearch("ad");
- assertSearchContainsReferenceField("campaign_ref", "campaign", search.getDocument());
- assertSearchContainsReferenceField("salesperson_ref", "salesperson", search.getDocument());
+ Schema schema = builder.getSearch("ad");
+ assertSearchContainsReferenceField("campaign_ref", "campaign", schema.getDocument());
+ assertSearchContainsReferenceField("salesperson_ref", "salesperson", schema.getDocument());
}
@Test
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReservedDocumentNamesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReservedDocumentNamesTestCase.java
index 3e61cec54da..6d722138871 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReservedDocumentNamesTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReservedDocumentNamesTestCase.java
@@ -21,7 +21,7 @@ public class ReservedDocumentNamesTestCase extends AbstractExportingTestCase {
assertCorrectDeriving("reserved_position");
fail();
} catch (IllegalArgumentException e) {
- assertEquals("For search 'position': Document name 'position' is reserved.", e.getMessage());
+ assertEquals("For schema 'position': Document name 'position' is reserved.", e.getMessage());
}
}
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/SearchMustHaveDocumentTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/SchemaMustHaveDocumentTest.java
index 4fe03fe0faa..34572280d01 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/SearchMustHaveDocumentTest.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/SchemaMustHaveDocumentTest.java
@@ -12,7 +12,7 @@ import static org.junit.Assert.fail;
/**
* @author hmusum
*/
-public class SearchMustHaveDocumentTest {
+public class SchemaMustHaveDocumentTest {
@Test
public void requireErrorWhenMissingDocument() throws IOException, ParseException {
@@ -21,7 +21,7 @@ public class SearchMustHaveDocumentTest {
fail("SD without document");
} catch (IllegalArgumentException e) {
if (!e.getMessage()
- .contains("For search 'imageconfig': A search specification must have an equally named document inside of it.")) {
+ .contains("For schema 'imageconfig': A search specification must have an equally named document inside of it.")) {
throw e;
}
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/SummaryConsistencyTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/SummaryConsistencyTestCase.java
index 71b4db60886..e0593aef1e3 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/SummaryConsistencyTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/SummaryConsistencyTestCase.java
@@ -1,7 +1,7 @@
// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.processing;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.SearchBuilder;
import com.yahoo.searchdefinition.parser.ParseException;
import com.yahoo.vespa.documentmodel.SummaryTransform;
@@ -39,7 +39,7 @@ public class SummaryConsistencyTestCase {
"",
"}"
);
- Search search = SearchBuilder.createFromString(sd).getSearch();
- assertEquals(SummaryTransform.ATTRIBUTECOMBINER, search.getSummaryField("elem_array_unfiltered").getTransform());
+ Schema schema = SearchBuilder.createFromString(sd).getSearch();
+ assertEquals(SummaryTransform.ATTRIBUTECOMBINER, schema.getSummaryField("elem_array_unfiltered").getTransform());
}
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/SummaryFieldsMustHaveValidSourceTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/SummaryFieldsMustHaveValidSourceTestCase.java
index adb6cc03d5b..014ca4ec5e9 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/SummaryFieldsMustHaveValidSourceTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/SummaryFieldsMustHaveValidSourceTestCase.java
@@ -4,9 +4,9 @@ package com.yahoo.searchdefinition.processing;
import com.yahoo.config.model.application.provider.BaseDeployLogger;
import com.yahoo.searchdefinition.RankProfileRegistry;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.SearchBuilder;
-import com.yahoo.searchdefinition.SchemaTestCase;
+import com.yahoo.searchdefinition.AbstractSchemaTestCase;
import com.yahoo.searchdefinition.parser.ParseException;
import com.yahoo.vespa.model.container.search.QueryProfiles;
import org.junit.Test;
@@ -16,7 +16,7 @@ import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-public class SummaryFieldsMustHaveValidSourceTestCase extends SchemaTestCase {
+public class SummaryFieldsMustHaveValidSourceTestCase extends AbstractSchemaTestCase {
@Test
public void requireThatInvalidSourceIsCaught() throws IOException, ParseException {
@@ -24,7 +24,7 @@ public class SummaryFieldsMustHaveValidSourceTestCase extends SchemaTestCase {
SearchBuilder.buildFromFile("src/test/examples/invalidsummarysource.sd");
fail("This should throw and never get here");
} catch (IllegalArgumentException e) {
- assertEquals("For search 'invalidsummarysource', summary class 'baz', summary field 'cox': there is no valid source 'nonexistingfield'.", e.getMessage());
+ assertEquals("For schema 'invalidsummarysource', summary class 'baz', summary field 'cox': there is no valid source 'nonexistingfield'.", e.getMessage());
}
}
@@ -34,7 +34,7 @@ public class SummaryFieldsMustHaveValidSourceTestCase extends SchemaTestCase {
SearchBuilder.buildFromFile("src/test/examples/invalidimplicitsummarysource.sd");
fail("This should throw and never get here");
} catch (IllegalArgumentException e) {
- assertEquals("For search 'invalidsummarysource', summary class 'baz', summary field 'cox': there is no valid source 'cox'.", e.getMessage());
+ assertEquals("For schema 'invalidsummarysource', summary class 'baz', summary field 'cox': there is no valid source 'cox'.", e.getMessage());
}
}
@@ -44,17 +44,17 @@ public class SummaryFieldsMustHaveValidSourceTestCase extends SchemaTestCase {
SearchBuilder.buildFromFile("src/test/examples/invalidselfreferringsummary.sd");
fail("This should throw and never get here");
} catch (IllegalArgumentException e) {
- assertEquals("For search 'invalidselfreferringsummary', summary class 'withid', summary field 'w': there is no valid source 'w'.", e.getMessage());
+ assertEquals("For schema 'invalidselfreferringsummary', summary class 'withid', summary field 'w': there is no valid source 'w'.", e.getMessage());
}
}
@Test
public void requireThatDocumentIdIsAllowedToPass() throws IOException, ParseException {
- Search search = SearchBuilder.buildFromFile("src/test/examples/documentidinsummary.sd");
+ Schema schema = SearchBuilder.buildFromFile("src/test/examples/documentidinsummary.sd");
BaseDeployLogger deployLogger = new BaseDeployLogger();
RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
- new SummaryFieldsMustHaveValidSource(search, deployLogger, rankProfileRegistry, new QueryProfiles()).process(true, false);
- assertEquals("documentid", search.getSummary("withid").getSummaryField("w").getSingleSource());
+ new SummaryFieldsMustHaveValidSource(schema, deployLogger, rankProfileRegistry, new QueryProfiles()).process(true, false);
+ assertEquals("documentid", schema.getSummary("withid").getSummaryField("w").getSingleSource());
}
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorFieldTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorFieldTestCase.java
index c8b0a826d48..cef00346fe7 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorFieldTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorFieldTestCase.java
@@ -26,7 +26,7 @@ public class TensorFieldTestCase {
fail("Expected exception");
}
catch (IllegalArgumentException e) {
- assertEquals("For search 'test', field 'f1': A field with collection type of tensor is not supported. Use simple type 'tensor' instead.",
+ assertEquals("For schema 'test', field 'f1': A field with collection type of tensor is not supported. Use simple type 'tensor' instead.",
e.getMessage());
}
}
@@ -38,7 +38,7 @@ public class TensorFieldTestCase {
fail("Expected exception");
}
catch (IllegalArgumentException e) {
- assertEquals("For search 'test', field 'f1': A tensor of type 'tensor(x{})' does not support having an 'index'. " +
+ assertEquals("For schema 'test', field 'f1': A tensor of type 'tensor(x{})' does not support having an 'index'. " +
"Currently, only tensors with 1 indexed dimension supports that.",
e.getMessage());
}
@@ -51,7 +51,7 @@ public class TensorFieldTestCase {
fail("Expected exception");
}
catch (IllegalArgumentException e) {
- assertEquals("For search 'test', field 'f1': An attribute of type 'tensor' cannot be 'fast-search'.", e.getMessage());
+ assertEquals("For schema 'test', field 'f1': An attribute of type 'tensor' cannot be 'fast-search'.", e.getMessage());
}
}
@@ -98,7 +98,7 @@ public class TensorFieldTestCase {
fail("Expected exception");
}
catch (IllegalArgumentException e) {
- assertEquals("For search 'test', field 't1': A tensor that has an index must also be an attribute.", e.getMessage());
+ assertEquals("For schema 'test', field 't1': A tensor that has an index must also be an attribute.", e.getMessage());
}
}
@@ -115,7 +115,7 @@ public class TensorFieldTestCase {
fail("Expected exception");
}
catch (IllegalArgumentException e) {
- assertEquals("For search 'test', field 't1': " +
+ assertEquals("For schema 'test', field 't1': " +
"A tensor that specifies hnsw index parameters must also specify 'index' in 'indexing'",
e.getMessage());
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java
index 8714568338f..888cd22c1c3 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/TensorTransformTestCase.java
@@ -3,7 +3,6 @@ package com.yahoo.searchdefinition.processing;
import com.yahoo.collections.Pair;
import com.yahoo.component.ComponentId;
-import com.yahoo.config.model.application.provider.BaseDeployLogger;
import com.yahoo.config.model.application.provider.MockFileRegistry;
import com.yahoo.config.model.deploy.TestProperties;
import com.yahoo.search.query.profile.QueryProfileRegistry;
@@ -14,9 +13,9 @@ import com.yahoo.search.query.profile.types.QueryProfileTypeRegistry;
import com.yahoo.searchdefinition.LargeRankExpressions;
import com.yahoo.searchdefinition.RankProfile;
import com.yahoo.searchdefinition.RankProfileRegistry;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.SearchBuilder;
-import com.yahoo.searchdefinition.SchemaTestCase;
+import com.yahoo.searchdefinition.AbstractSchemaTestCase;
import com.yahoo.searchdefinition.derived.AttributeFields;
import com.yahoo.searchdefinition.derived.RawRankProfile;
import com.yahoo.searchdefinition.parser.ParseException;
@@ -28,7 +27,7 @@ import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-public class TensorTransformTestCase extends SchemaTestCase {
+public class TensorTransformTestCase extends AbstractSchemaTestCase {
@Test
public void requireThatNormalMaxAndMinAreNotReplaced() throws ParseException {
@@ -199,7 +198,7 @@ public class TensorTransformTestCase extends SchemaTestCase {
" }\n" +
"}\n");
builder.build(true);
- Search s = builder.getSearch();
+ Schema s = builder.getSearch();
RankProfile test = rankProfileRegistry.get(s, "test").compile(queryProfiles, new ImportedMlModels());
List<Pair<String, String>> testRankProperties = new RawRankProfile(test,
new LargeRankExpressions(new MockFileRegistry()),
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ValidateFieldTypesTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ValidateFieldTypesTest.java
index c7b9ce16338..08c123b5578 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ValidateFieldTypesTest.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ValidateFieldTypesTest.java
@@ -6,8 +6,9 @@ import com.yahoo.config.model.deploy.TestProperties;
import com.yahoo.config.model.test.MockApplicationPackage;
import com.yahoo.document.DataType;
import com.yahoo.document.Field;
+import com.yahoo.searchdefinition.Application;
import com.yahoo.searchdefinition.DocumentReference;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.derived.TestableDeployLogger;
import com.yahoo.searchdefinition.document.ImportedField;
import com.yahoo.searchdefinition.document.ImportedFields;
@@ -35,39 +36,43 @@ public class ValidateFieldTypesTest {
@Test
public void throws_exception_if_type_of_document_field_does_not_match_summary_field() {
- Search search = createSearchWithDocument(DOCUMENT_NAME);
- search.setImportedFields(createSingleImportedField(IMPORTED_FIELD_NAME, DataType.INT));
- search.addSummary(createDocumentSummary(IMPORTED_FIELD_NAME, DataType.STRING, search));
+ Schema schema = createSearchWithDocument(DOCUMENT_NAME);
+ schema.setImportedFields(createSingleImportedField(IMPORTED_FIELD_NAME, DataType.INT));
+ schema.addSummary(createDocumentSummary(IMPORTED_FIELD_NAME, DataType.STRING, schema));
- ValidateFieldTypes validator = new ValidateFieldTypes(search, null, null, null);
+ ValidateFieldTypes validator = new ValidateFieldTypes(schema, null, null, null);
exceptionRule.expect(IllegalArgumentException.class);
exceptionRule.expectMessage(
- "For search '" + DOCUMENT_NAME + "', field '" + IMPORTED_FIELD_NAME + "': Incompatible types. " +
+ "For schema '" + DOCUMENT_NAME + "', field '" + IMPORTED_FIELD_NAME + "': Incompatible types. " +
"Expected int for summary field '" + IMPORTED_FIELD_NAME + "', got string.");
validator.process(true, false);
}
- private static Search createSearch(String documentType) {
- return new Search(documentType, MockApplicationPackage.createEmpty(), new MockFileRegistry(), new TestableDeployLogger(), new TestProperties());
+ private static Schema createSearch(String documentType) {
+ return new Schema(documentType,
+ new Application(MockApplicationPackage.createEmpty()),
+ new MockFileRegistry(),
+ new TestableDeployLogger(),
+ new TestProperties());
}
- private static Search createSearchWithDocument(String documentName) {
- Search search = createSearch(documentName);
- SDDocumentType document = new SDDocumentType(documentName, search);
- search.addDocument(document);
- return search;
+ private static Schema createSearchWithDocument(String documentName) {
+ Schema schema = createSearch(documentName);
+ SDDocumentType document = new SDDocumentType(documentName, schema);
+ schema.addDocument(document);
+ return schema;
}
private static ImportedFields createSingleImportedField(String fieldName, DataType dataType) {
- Search targetSearch = createSearch("target_doc");
+ Schema targetSchema = createSearch("target_doc");
SDField targetField = new SDField("target_field", dataType);
- DocumentReference documentReference = new DocumentReference(new Field("reference_field"), targetSearch);
+ DocumentReference documentReference = new DocumentReference(new Field("reference_field"), targetSchema);
ImportedField importedField = new ImportedSimpleField(fieldName, documentReference, targetField);
return new ImportedFields(Collections.singletonMap(fieldName, importedField));
}
- private static DocumentSummary createDocumentSummary(String fieldName, DataType dataType, Search search) {
- DocumentSummary summary = new DocumentSummary("mysummary", search);
+ private static DocumentSummary createDocumentSummary(String fieldName, DataType dataType, Schema schema) {
+ DocumentSummary summary = new DocumentSummary("mysummary", schema);
summary.add(new SummaryField(fieldName, dataType));
return summary;
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/WeightedSetSummaryToTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/WeightedSetSummaryToTestCase.java
index 3b2875d303c..e9aec9b7293 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/WeightedSetSummaryToTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/WeightedSetSummaryToTestCase.java
@@ -1,9 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.processing;
-import com.yahoo.searchdefinition.Search;
+import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.SearchBuilder;
-import com.yahoo.searchdefinition.SchemaTestCase;
+import com.yahoo.searchdefinition.AbstractSchemaTestCase;
import com.yahoo.searchdefinition.parser.ParseException;
import org.junit.Test;
@@ -12,12 +12,12 @@ import java.io.IOException;
import static org.junit.Assert.assertNotNull;
/** @author bratseth */
-public class WeightedSetSummaryToTestCase extends SchemaTestCase {
+public class WeightedSetSummaryToTestCase extends AbstractSchemaTestCase {
@Test
public void testRequireThatImplicitFieldsAreCreated() throws IOException, ParseException {
- Search search = SearchBuilder.buildFromFile("src/test/examples/weightedset-summaryto.sd");
- assertNotNull(search);
+ Schema schema = SearchBuilder.buildFromFile("src/test/examples/weightedset-summaryto.sd");
+ assertNotNull(schema);
}
}