From 7cfec9da18f7e1fc5d23cafef64c5f7b7af3750f Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Mon, 25 Oct 2021 12:34:56 +0200 Subject: SearchBuilder -> SchemaBuilder --- .../com/yahoo/config/model/deploy/DeployState.java | 4 +- .../config/model/deploy/SearchDocumentModel.java | 6 +- .../config/model/test/MockApplicationPackage.java | 6 +- .../com/yahoo/searchdefinition/SchemaBuilder.java | 555 +++++++++++++++++++++ .../com/yahoo/searchdefinition/SearchBuilder.java | 555 --------------------- .../yahoo/searchdefinition/derived/Deriver.java | 6 +- .../com/yahoo/searchdefinition/ArraysTestCase.java | 2 +- .../ArraysWeightedSetsTestCase.java | 2 +- .../AttributeSettingsTestCase.java | 6 +- .../yahoo/searchdefinition/CommentTestCase.java | 2 +- .../yahoo/searchdefinition/DiversityTestCase.java | 10 +- .../IncorrectRankingExpressionFileRefTestCase.java | 2 +- .../IncorrectSummaryTypesTestCase.java | 2 +- .../searchdefinition/IndexSettingsTestCase.java | 4 +- .../searchdefinition/IndexingParsingTestCase.java | 4 +- .../MultipleSummariesTestCase.java | 2 +- .../searchdefinition/NameFieldCheckTestCase.java | 6 +- .../yahoo/searchdefinition/OutsideTestCase.java | 4 +- .../PredicateDataTypeTestCase.java | 20 +- .../searchdefinition/RankProfileTestCase.java | 22 +- .../searchdefinition/RankPropertiesTestCase.java | 4 +- .../searchdefinition/RankingConstantTest.java | 60 +-- .../RankingExpressionConstantsTestCase.java | 12 +- .../RankingExpressionInliningTestCase.java | 8 +- .../RankingExpressionLoopDetectionTestCase.java | 16 +- .../RankingExpressionShadowingTestCase.java | 8 +- .../RankingExpressionValidationTestCase.java | 2 +- .../ReservedWordsAsFieldNamesTestCase.java | 2 +- .../searchdefinition/SchemaImporterTestCase.java | 6 +- .../searchdefinition/SchemaParsingTestCase.java | 14 +- .../com/yahoo/searchdefinition/SchemaTestCase.java | 8 +- .../searchdefinition/StemmingSettingTestCase.java | 4 +- .../com/yahoo/searchdefinition/StructTestCase.java | 4 +- .../yahoo/searchdefinition/SummaryTestCase.java | 16 +- .../UrlFieldValidationTestCase.java | 2 +- .../derived/AbstractExportingTestCase.java | 14 +- .../derived/AttributeListTestCase.java | 12 +- .../searchdefinition/derived/CasingTestCase.java | 4 +- .../derived/EmptyRankProfileTestCase.java | 4 +- .../derived/ExportingTestCase.java | 4 +- .../derived/InheritanceTestCase.java | 12 +- .../derived/LiteralBoostTestCase.java | 6 +- .../searchdefinition/derived/MailTestCase.java | 4 +- .../derived/SchemaInheritanceTestCase.java | 5 +- .../derived/SimpleInheritTestCase.java | 4 +- .../derived/SummaryMapTestCase.java | 6 +- .../searchdefinition/derived/SummaryTestCase.java | 12 +- .../derived/TwoStreamingStructsTestCase.java | 6 +- .../ComplexAttributeFieldUtilsTestCase.java | 4 +- .../processing/AssertSearchBuilder.java | 6 +- .../processing/AttributesExactMatchTestCase.java | 4 +- .../processing/BoldingTestCase.java | 6 +- .../processing/BoolAttributeValidatorTestCase.java | 2 +- .../processing/DictionaryTestCase.java | 8 +- .../DisallowComplexMapAndWsetKeyTypesTestCase.java | 4 +- .../processing/FastAccessValidatorTest.java | 4 +- .../processing/ImplicitSchemaFieldsTestCase.java | 14 +- .../processing/ImplicitStructTypesTestCase.java | 6 +- .../processing/ImplicitSummariesTestCase.java | 10 +- .../processing/ImplicitSummaryFieldsTestCase.java | 4 +- .../processing/ImportedFieldsTestCase.java | 12 +- .../processing/IndexingScriptRewriterTestCase.java | 6 +- .../processing/IndexingValidationTestCase.java | 4 +- .../processing/IntegerIndex2AttributeTestCase.java | 4 +- .../MatchedElementsOnlyResolverTestCase.java | 4 +- .../searchdefinition/processing/NGramTestCase.java | 10 +- .../PagedAttributeValidatorTestCase.java | 2 +- .../processing/PositionTestCase.java | 14 +- .../processing/RankModifierTestCase.java | 4 +- .../processing/RankProfileSearchFixture.java | 4 +- .../processing/RankPropertyVariablesTestCase.java | 4 +- .../RankingExpressionTypeResolverTestCase.java | 32 +- ...ingExpressionWithTransformerTokensTestCase.java | 10 +- .../processing/RankingExpressionsTestCase.java | 4 +- .../processing/ReferenceFieldTestCase.java | 6 +- ...rvedRankingExpressionFunctionNamesTestCase.java | 4 +- .../processing/SchemaMustHaveDocumentTest.java | 4 +- .../processing/SummaryConsistencyTestCase.java | 4 +- .../SummaryFieldsMustHaveValidSourceTestCase.java | 10 +- .../processing/TensorFieldTestCase.java | 3 +- .../processing/TensorTransformTestCase.java | 4 +- .../processing/WeightedSetSummaryToTestCase.java | 4 +- ...DocumentModelBuilderImportedFieldsTestCase.java | 4 +- .../DocumentModelBuilderReferenceTypeTestCase.java | 4 +- .../DocumentModelBuilderTestCase.java | 8 +- .../vespa/model/search/test/SchemaClusterTest.java | 4 +- 86 files changed, 861 insertions(+), 863 deletions(-) create mode 100644 config-model/src/main/java/com/yahoo/searchdefinition/SchemaBuilder.java delete mode 100644 config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java (limited to 'config-model') diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java b/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java index 4790b9e8d27..dac62ce7e1b 100644 --- a/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java +++ b/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java @@ -30,7 +30,7 @@ import com.yahoo.config.provision.Zone; import com.yahoo.io.IOUtils; import com.yahoo.io.reader.NamedReader; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.config.ConfigDefinition; import com.yahoo.vespa.config.ConfigDefinitionBuilder; @@ -475,7 +475,7 @@ public class DeployState implements ConfigDefinitionStore { ValidationParameters validationParameters) { Collection readers = applicationPackage.getSchemas(); Map names = new LinkedHashMap<>(); - SearchBuilder builder = new SearchBuilder(applicationPackage, fileRegistry, logger, properties, rankProfileRegistry, queryProfiles.getRegistry()); + SchemaBuilder builder = new SchemaBuilder(applicationPackage, fileRegistry, logger, properties, rankProfileRegistry, queryProfiles.getRegistry()); for (NamedReader reader : readers) { try { String readerName = reader.getName(); diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/SearchDocumentModel.java b/config-model/src/main/java/com/yahoo/config/model/deploy/SearchDocumentModel.java index 604e2b0a44b..b7a44ef2c73 100644 --- a/config-model/src/main/java/com/yahoo/config/model/deploy/SearchDocumentModel.java +++ b/config-model/src/main/java/com/yahoo/config/model/deploy/SearchDocumentModel.java @@ -2,7 +2,7 @@ package com.yahoo.config.model.deploy; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.vespa.documentmodel.DocumentModel; import com.yahoo.vespa.model.search.NamedSchema; @@ -34,7 +34,7 @@ public class SearchDocumentModel { return schemas; } - public static SearchDocumentModel fromBuilderAndNames(SearchBuilder builder, Map names) { + public static SearchDocumentModel fromBuilderAndNames(SchemaBuilder builder, Map names) { List ret = new ArrayList<>(); for (Schema schema : builder.getSearchList()) { ret.add(new NamedSchema(names.get(schema.getName()), schema)); @@ -42,7 +42,7 @@ public class SearchDocumentModel { return new SearchDocumentModel(builder.getModel(), ret); } - public static SearchDocumentModel fromBuilder(SearchBuilder builder) { + public static SearchDocumentModel fromBuilder(SchemaBuilder builder) { List ret = new ArrayList<>(); for (Schema schema : builder.getSearchList()) { ret.add(new NamedSchema(schema.getName(), schema)); diff --git a/config-model/src/main/java/com/yahoo/config/model/test/MockApplicationPackage.java b/config-model/src/main/java/com/yahoo/config/model/test/MockApplicationPackage.java index 1ef5dcef411..5822b1bca05 100644 --- a/config-model/src/main/java/com/yahoo/config/model/test/MockApplicationPackage.java +++ b/config-model/src/main/java/com/yahoo/config/model/test/MockApplicationPackage.java @@ -19,7 +19,7 @@ import com.yahoo.io.reader.NamedReader; import com.yahoo.search.query.profile.QueryProfileRegistry; import com.yahoo.search.query.profile.config.QueryProfileXMLReader; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.config.ConfigDefinitionKey; import com.yahoo.config.application.api.ApplicationPackage; @@ -118,7 +118,7 @@ public class MockApplicationPackage implements ApplicationPackage { @Override public List getSchemas() { ArrayList readers = new ArrayList<>(); - SearchBuilder searchBuilder = new SearchBuilder(this, + SchemaBuilder schemaBuilder = new SchemaBuilder(this, new MockFileRegistry(), new BaseDeployLogger(), new TestProperties(), @@ -126,7 +126,7 @@ public class MockApplicationPackage implements ApplicationPackage { queryProfileRegistry); for (String sd : schemas) { try { - String name = searchBuilder.importString(sd); + String name = schemaBuilder.importString(sd); readers.add(new NamedReader(name + ApplicationPackage.SD_NAME_SUFFIX, new StringReader(sd))); } catch (ParseException e) { throw new RuntimeException(e); diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/SchemaBuilder.java b/config-model/src/main/java/com/yahoo/searchdefinition/SchemaBuilder.java new file mode 100644 index 00000000000..a2d7fdd8fe5 --- /dev/null +++ b/config-model/src/main/java/com/yahoo/searchdefinition/SchemaBuilder.java @@ -0,0 +1,555 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.searchdefinition; + +import com.yahoo.config.application.api.ApplicationPackage; +import com.yahoo.config.application.api.DeployLogger; +import com.yahoo.config.application.api.FileRegistry; +import com.yahoo.config.model.api.ModelContext; +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.config.model.test.MockApplicationPackage; +import com.yahoo.document.DocumentTypeManager; +import com.yahoo.io.IOUtils; +import com.yahoo.io.reader.NamedReader; +import com.yahoo.search.query.profile.QueryProfileRegistry; +import com.yahoo.search.query.profile.config.QueryProfileXMLReader; +import com.yahoo.searchdefinition.derived.SearchOrderer; +import com.yahoo.searchdefinition.document.SDDocumentType; +import com.yahoo.searchdefinition.parser.ParseException; +import com.yahoo.searchdefinition.parser.SDParser; +import com.yahoo.searchdefinition.parser.SimpleCharStream; +import com.yahoo.searchdefinition.parser.TokenMgrException; +import com.yahoo.searchdefinition.processing.Processing; +import com.yahoo.searchdefinition.processing.Processor; +import com.yahoo.vespa.documentmodel.DocumentModel; +import com.yahoo.vespa.model.container.search.QueryProfiles; +import com.yahoo.yolean.Exceptions; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +/** + * Helper class for importing {@link Schema} objects in an unambiguous way. The pattern for using this is to 1) Import + * all available search definitions, using the importXXX() methods, 2) provide the available rank types and rank + * expressions, using the setRankXXX() methods, 3) invoke the {@link #build()} method, and 4) retrieve the built + * search objects using the {@link #getSearch(String)} method. + */ +// NOTE: Since this was created we have added Application, and much of the content in this should migrate there. +public class SchemaBuilder { + + private final DocumentTypeManager docTypeMgr = new DocumentTypeManager(); + private final DocumentModel model = new DocumentModel(); + private final Application application; + private final QueryProfileRegistry queryProfileRegistry; + private final FileRegistry fileRegistry; + private final DeployLogger deployLogger; + private final ModelContext.Properties properties; + /** True to build the document aspect only, skipping instantiation of rank profiles */ + private final boolean documentsOnly; + + private List schemaList = new LinkedList<>(); + private boolean isBuilt = false; + + private final Set> processorsToSkip = new HashSet<>(); + + /** For testing only */ + public SchemaBuilder() { + this(new RankProfileRegistry(), new QueryProfileRegistry()); + } + + /** For testing only */ + public SchemaBuilder(DeployLogger deployLogger) { + this(MockApplicationPackage.createEmpty(), deployLogger); + } + + /** For testing only */ + public SchemaBuilder(DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry) { + this(MockApplicationPackage.createEmpty(), deployLogger, rankProfileRegistry); + } + + /** Used for generating documents for typed access to document fields in Java */ + public SchemaBuilder(boolean documentsOnly) { + this(MockApplicationPackage.createEmpty(), new MockFileRegistry(), new BaseDeployLogger(), new TestProperties(), new RankProfileRegistry(), new QueryProfileRegistry(), documentsOnly); + } + + /** For testing only */ + public SchemaBuilder(ApplicationPackage app, DeployLogger deployLogger) { + this(app, new MockFileRegistry(), deployLogger, new TestProperties(), new RankProfileRegistry(), new QueryProfileRegistry()); + } + + /** For testing only */ + public SchemaBuilder(ApplicationPackage app, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry) { + this(app, new MockFileRegistry(), deployLogger, new TestProperties(), rankProfileRegistry, new QueryProfileRegistry()); + } + + /** For testing only */ + public SchemaBuilder(RankProfileRegistry rankProfileRegistry) { + this(rankProfileRegistry, new QueryProfileRegistry()); + } + + /** For testing only */ + public SchemaBuilder(RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfileRegistry) { + this(rankProfileRegistry, queryProfileRegistry, new TestProperties()); + } + public SchemaBuilder(RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfileRegistry, ModelContext.Properties properties) { + this(MockApplicationPackage.createEmpty(), new MockFileRegistry(), new BaseDeployLogger(), properties, rankProfileRegistry, queryProfileRegistry); + } + + public SchemaBuilder(ApplicationPackage app, + FileRegistry fileRegistry, + DeployLogger deployLogger, + ModelContext.Properties properties, + RankProfileRegistry rankProfileRegistry, + QueryProfileRegistry queryProfileRegistry) { + this(app, fileRegistry, deployLogger, properties, rankProfileRegistry, queryProfileRegistry, false); + } + private SchemaBuilder(ApplicationPackage applicationPackage, + FileRegistry fileRegistry, + DeployLogger deployLogger, + ModelContext.Properties properties, + RankProfileRegistry rankProfileRegistry, + QueryProfileRegistry queryProfileRegistry, + boolean documentsOnly) { + this.application = new Application(applicationPackage, rankProfileRegistry); + this.queryProfileRegistry = queryProfileRegistry; + this.fileRegistry = fileRegistry; + this.deployLogger = deployLogger; + this.properties = properties; + this.documentsOnly = documentsOnly; + } + + /** + * Import search definition. + * + * @param fileName the name of the file to import + * @return the name of the imported object + * @throws IOException thrown if the file can not be read for some reason + * @throws ParseException thrown if the file does not contain a valid search definition + */ + public String importFile(String fileName) throws IOException, ParseException { + File file = new File(fileName); + return importString(IOUtils.readFile(file), file.getAbsoluteFile().getParent()); + } + + private String importFile(Path file) throws IOException, ParseException { + return importFile(file.toString()); + } + + /** + * Reads and parses the search definition string provided by the given reader. Once all search definitions have been + * imported, call {@link #build()}. + * + * @param reader the reader whose content to import + * @param searchDefDir the path to use when resolving file references + * @return the name of the imported object + * @throws ParseException thrown if the file does not contain a valid search definition + */ + public String importReader(NamedReader reader, String searchDefDir) throws IOException, ParseException { + return importString(IOUtils.readAll(reader), searchDefDir); + } + + /** + * Import search definition. + * + * @param str the string to parse. + * @return the name of the imported object. + * @throws ParseException thrown if the file does not contain a valid search definition. + */ + public String importString(String str) throws ParseException { + return importString(str, null); + } + + private String importString(String str, String searchDefDir) throws ParseException { + SimpleCharStream stream = new SimpleCharStream(str); + try { + return importRawSearch(new SDParser(stream, fileRegistry, deployLogger, properties, application, + application.rankProfileRegistry(), documentsOnly) + .schema(docTypeMgr, searchDefDir)); + } catch (TokenMgrException e) { + throw new ParseException("Unknown symbol: " + e.getMessage()); + } catch (ParseException pe) { + throw new ParseException(stream.formatException(Exceptions.toMessageString(pe))); + } + } + + /** + * Registers the given search object to the internal list of objects to be processed during {@link #build()}. A + * {@link Schema} object is considered to be "raw" if it has not already been processed. This is the case for most + * programmatically constructed search objects used in unit tests. + * + * @param schema the object to import. + * @return the name of the imported object. + * @throws IllegalArgumentException if the given search object has already been processed. + */ + public String importRawSearch(Schema schema) { + if (schema.getName() == null) + throw new IllegalArgumentException("Schema has no name"); + String rawName = schema.getName(); + application.add(schema); + schemaList.add(schema); + return rawName; + } + + /** + * Only for testing. + * + * Processes and finalizes the imported search definitions so that they become available through the {@link + * #getSearch(String)} method. + * + * @throws IllegalStateException Thrown if this method has already been called. + */ + public void build() { + build(true); + } + + /** + * Processes and finalizes the imported search definitions so that they become available through the {@link + * #getSearch(String)} method. + * + * @throws IllegalStateException Thrown if this method has already been called. + */ + public void build(boolean validate) { + if (isBuilt) throw new IllegalStateException("Model already built"); + + if (validate) + application.validate(deployLogger); + + List built = new ArrayList<>(); + List sdocs = new ArrayList<>(); + sdocs.add(SDDocumentType.VESPA_DOCUMENT); + for (Schema schema : schemaList) { + if (schema.hasDocument()) { + sdocs.add(schema.getDocument()); + } + } + + var orderer = new SDDocumentTypeOrderer(sdocs, deployLogger); + orderer.process(); + for (SDDocumentType sdoc : orderer.getOrdered()) { + new FieldOperationApplierForStructs().process(sdoc); + new FieldOperationApplier().process(sdoc); + } + + var resolver = new DocumentReferenceResolver(schemaList); + sdocs.forEach(resolver::resolveReferences); + sdocs.forEach(resolver::resolveInheritedReferences); + var importedFieldsEnumerator = new ImportedFieldsEnumerator(schemaList); + sdocs.forEach(importedFieldsEnumerator::enumerateImportedFields); + + if (validate) + new DocumentGraphValidator().validateDocumentGraph(sdocs); + + var builder = new DocumentModelBuilder(model); + for (Schema schema : new SearchOrderer().order(schemaList)) { + new FieldOperationApplierForSearch().process(schema); // TODO: Why is this not in the regular list? + process(schema, new QueryProfiles(queryProfileRegistry, deployLogger), validate); + built.add(schema); + } + builder.addToModel(schemaList); + + if ( validate && ! builder.valid() ) + throw new IllegalArgumentException("Impossible to build a correct model"); + + schemaList = built; + isBuilt = true; + } + + /** Returns a modifiable set of processors we should skip for these schemas. Useful for testing. */ + public Set> processorsToSkip() { return processorsToSkip; } + + /** + * Processes and returns the given {@link Schema} object. This method has been factored out of the {@link + * #build()} method so that subclasses can choose not to build anything. + */ + private void process(Schema schema, QueryProfiles queryProfiles, boolean validate) { + new Processing().process(schema, deployLogger, application.rankProfileRegistry(), queryProfiles, validate, + documentsOnly, processorsToSkip); + } + + /** + * Convenience method to call {@link #getSearch(String)} when there is only a single {@link Schema} object + * built. This method will never return null. + * + * @return the built object + * @throws IllegalStateException if there is not exactly one search. + */ + public Schema getSearch() { + if ( ! isBuilt) throw new IllegalStateException("Searches not built."); + if (application.schemas().size() != 1) + throw new IllegalStateException("This call only works if we have 1 schema. Schemas: " + + application.schemas().values()); + + return application.schemas().values().stream().findAny().get(); + } + + public DocumentModel getModel() { + return model; + } + + /** + * Returns the built {@link Schema} object that has the given name. If the name is unknown, this method will simply + * return null. + * + * @param name the name of the search definition to return, + * or null to return the only one or throw an exception if there are multiple to choose from + * @return the built object, or null if none with this name + * @throws IllegalStateException if {@link #build()} has not been called. + */ + public Schema getSearch(String name) { + if ( ! isBuilt) throw new IllegalStateException("Searches not built."); + if (name == null) return getSearch(); + return application.schemas().get(name); + } + + public Application application() { return application; } + + /** + * Convenience method to return a list of all built {@link Schema} objects. + * + * @return the list of built searches + */ + public List getSearchList() { + return new ArrayList<>(schemaList); + } + + /** + * Convenience factory method to import and build a {@link Schema} object from a string. + * + * @param sd The string to build from. + * @return The built {@link SchemaBuilder} object. + * @throws ParseException Thrown if there was a problem parsing the string. + */ + public static SchemaBuilder createFromString(String sd) throws ParseException { + return createFromString(sd, new BaseDeployLogger()); + } + + public static SchemaBuilder createFromString(String sd, DeployLogger logger) throws ParseException { + SchemaBuilder builder = new SchemaBuilder(logger); + builder.importString(sd); + builder.build(true); + return builder; + } + + public static SchemaBuilder createFromStrings(DeployLogger logger, String ... schemas) throws ParseException { + SchemaBuilder builder = new SchemaBuilder(logger); + for (var schema : schemas) + builder.importString(schema); + builder.build(true); + return builder; + } + + /** + * Convenience factory method to import and build a {@link Schema} object from a file. Only for testing. + * + * @param fileName the file to build from + * @return the built {@link SchemaBuilder} object + * @throws IOException if there was a problem reading the file. + * @throws ParseException if there was a problem parsing the file content. + */ + public static SchemaBuilder createFromFile(String fileName) throws IOException, ParseException { + return createFromFile(fileName, new BaseDeployLogger()); + } + + /** + * Convenience factory methdd to create a SearchBuilder from multiple SD files. Only for testing. + */ + public static SchemaBuilder createFromFiles(Collection fileNames) throws IOException, ParseException { + return createFromFiles(fileNames, new BaseDeployLogger()); + } + + public static SchemaBuilder createFromFile(String fileName, DeployLogger logger) throws IOException, ParseException { + return createFromFile(fileName, logger, new RankProfileRegistry(), new QueryProfileRegistry()); + } + + private static SchemaBuilder createFromFiles(Collection fileNames, DeployLogger logger) throws IOException, ParseException { + return createFromFiles(fileNames, new MockFileRegistry(), logger, new TestProperties(), new RankProfileRegistry(), new QueryProfileRegistry()); + } + + /** + * Convenience factory method to import and build a {@link Schema} object from a file. + * + * @param fileName the file to build from. + * @param deployLogger logger for deploy messages. + * @param rankProfileRegistry registry for rank profiles. + * @return the built {@link SchemaBuilder} object. + * @throws IOException if there was a problem reading the file. + * @throws ParseException if there was a problem parsing the file content. + */ + private static SchemaBuilder createFromFile(String fileName, + DeployLogger deployLogger, + RankProfileRegistry rankProfileRegistry, + QueryProfileRegistry queryprofileRegistry) + throws IOException, ParseException { + return createFromFiles(Collections.singletonList(fileName), new MockFileRegistry(), deployLogger, new TestProperties(), + rankProfileRegistry, queryprofileRegistry); + } + + /** + * Convenience factory methdd to create a SearchBuilder from multiple SD files.. + */ + private static SchemaBuilder createFromFiles(Collection fileNames, + FileRegistry fileRegistry, + DeployLogger deployLogger, + ModelContext.Properties properties, + RankProfileRegistry rankProfileRegistry, + QueryProfileRegistry queryprofileRegistry) + throws IOException, ParseException { + SchemaBuilder builder = new SchemaBuilder(MockApplicationPackage.createEmpty(), + fileRegistry, + deployLogger, + properties, + rankProfileRegistry, + queryprofileRegistry); + for (String fileName : fileNames) { + builder.importFile(fileName); + } + builder.build(true); + return builder; + } + + + public static SchemaBuilder createFromDirectory(String dir, FileRegistry fileRegistry, DeployLogger logger, ModelContext.Properties properties) throws IOException, ParseException { + return createFromDirectory(dir, fileRegistry, logger, properties, new RankProfileRegistry()); + } + public static SchemaBuilder createFromDirectory(String dir, + FileRegistry fileRegistry, + DeployLogger logger, + ModelContext.Properties properties, + RankProfileRegistry rankProfileRegistry) throws IOException, ParseException { + return createFromDirectory(dir, fileRegistry, logger, properties, rankProfileRegistry, createQueryProfileRegistryFromDirectory(dir)); + } + private static SchemaBuilder createFromDirectory(String dir, + FileRegistry fileRegistry, + DeployLogger logger, + ModelContext.Properties properties, + RankProfileRegistry rankProfileRegistry, + QueryProfileRegistry queryProfileRegistry) throws IOException, ParseException { + return createFromDirectory(dir, MockApplicationPackage.fromSearchDefinitionAndRootDirectory(dir), fileRegistry, logger, properties, + rankProfileRegistry, queryProfileRegistry); + } + + private static SchemaBuilder createFromDirectory(String dir, + ApplicationPackage applicationPackage, + FileRegistry fileRegistry, + DeployLogger deployLogger, + ModelContext.Properties properties, + RankProfileRegistry rankProfileRegistry, + QueryProfileRegistry queryProfileRegistry) throws IOException, ParseException { + SchemaBuilder builder = new SchemaBuilder(applicationPackage, + fileRegistry, + deployLogger, + properties, + rankProfileRegistry, + queryProfileRegistry); + for (Iterator i = Files.list(new File(dir).toPath()).filter(p -> p.getFileName().toString().endsWith(".sd")).iterator(); i.hasNext(); ) { + builder.importFile(i.next()); + } + builder.build(true); + return builder; + } + + private static QueryProfileRegistry createQueryProfileRegistryFromDirectory(String dir) { + File queryProfilesDir = new File(dir, "query-profiles"); + if ( ! queryProfilesDir.exists()) return new QueryProfileRegistry(); + return new QueryProfileXMLReader().read(queryProfilesDir.toString()); + } + + // TODO: The build methods below just call the create methods above - remove + + /** + * Convenience factory method to import and build a {@link Schema} object from a file. Only for testing. + * + * @param fileName The file to build from. + * @return The built {@link Schema} object. + * @throws IOException Thrown if there was a problem reading the file. + * @throws ParseException Thrown if there was a problem parsing the file content. + */ + public static Schema buildFromFile(String fileName) throws IOException, ParseException { + return buildFromFile(fileName, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfileRegistry()); + } + + /** + * Convenience factory method to import and build a {@link Schema} object from a file. + * + * @param fileName The file to build from. + * @param rankProfileRegistry Registry for rank profiles. + * @return The built {@link Schema} object. + * @throws IOException Thrown if there was a problem reading the file. + * @throws ParseException Thrown if there was a problem parsing the file content. + */ + public static Schema buildFromFile(String fileName, + RankProfileRegistry rankProfileRegistry, + QueryProfileRegistry queryProfileRegistry) + throws IOException, ParseException { + return buildFromFile(fileName, new BaseDeployLogger(), rankProfileRegistry, queryProfileRegistry); + } + + /** + * Convenience factory method to import and build a {@link Schema} object from a file. + * + * @param fileName The file to build from. + * @param deployLogger Logger for deploy messages. + * @param rankProfileRegistry Registry for rank profiles. + * @return The built {@link Schema} object. + * @throws IOException Thrown if there was a problem reading the file. + * @throws ParseException Thrown if there was a problem parsing the file content. + */ + public static Schema buildFromFile(String fileName, + DeployLogger deployLogger, + RankProfileRegistry rankProfileRegistry, + QueryProfileRegistry queryProfileRegistry) + throws IOException, ParseException { + return createFromFile(fileName, deployLogger, rankProfileRegistry, queryProfileRegistry).getSearch(); + } + + /** + * Convenience factory method to import and build a {@link Schema} object from a raw object. + * + * @param rawSchema the raw object to build from. + * @return the built {@link SchemaBuilder} object. + * @see #importRawSearch(Schema) + */ + public static SchemaBuilder createFromRawSearch(Schema rawSchema, + RankProfileRegistry rankProfileRegistry, + QueryProfileRegistry queryProfileRegistry) { + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry, queryProfileRegistry); + builder.importRawSearch(rawSchema); + builder.build(); + return builder; + } + + /** + * Convenience factory method to import and build a {@link Schema} object from a raw object. + * + * @param rawSchema The raw object to build from. + * @return The built {@link Schema} object. + * @see #importRawSearch(Schema) + */ + public static Schema buildFromRawSearch(Schema rawSchema, + RankProfileRegistry rankProfileRegistry, + QueryProfileRegistry queryProfileRegistry) { + return createFromRawSearch(rawSchema, rankProfileRegistry, queryProfileRegistry).getSearch(); + } + + public RankProfileRegistry getRankProfileRegistry() { + return application.rankProfileRegistry(); + } + + public QueryProfileRegistry getQueryProfileRegistry() { + return queryProfileRegistry; + } + public ModelContext.Properties getProperties() { return properties; } + public DeployLogger getDeployLogger() { return deployLogger; } + +} diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java b/config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java deleted file mode 100644 index dc5ab752f31..00000000000 --- a/config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java +++ /dev/null @@ -1,555 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.searchdefinition; - -import com.yahoo.config.application.api.ApplicationPackage; -import com.yahoo.config.application.api.DeployLogger; -import com.yahoo.config.application.api.FileRegistry; -import com.yahoo.config.model.api.ModelContext; -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.config.model.test.MockApplicationPackage; -import com.yahoo.document.DocumentTypeManager; -import com.yahoo.io.IOUtils; -import com.yahoo.io.reader.NamedReader; -import com.yahoo.search.query.profile.QueryProfileRegistry; -import com.yahoo.search.query.profile.config.QueryProfileXMLReader; -import com.yahoo.searchdefinition.derived.SearchOrderer; -import com.yahoo.searchdefinition.document.SDDocumentType; -import com.yahoo.searchdefinition.parser.ParseException; -import com.yahoo.searchdefinition.parser.SDParser; -import com.yahoo.searchdefinition.parser.SimpleCharStream; -import com.yahoo.searchdefinition.parser.TokenMgrException; -import com.yahoo.searchdefinition.processing.Processing; -import com.yahoo.searchdefinition.processing.Processor; -import com.yahoo.vespa.documentmodel.DocumentModel; -import com.yahoo.vespa.model.container.search.QueryProfiles; -import com.yahoo.yolean.Exceptions; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; - -/** - * Helper class for importing {@link Schema} objects in an unambiguous way. The pattern for using this is to 1) Import - * all available search definitions, using the importXXX() methods, 2) provide the available rank types and rank - * expressions, using the setRankXXX() methods, 3) invoke the {@link #build()} method, and 4) retrieve the built - * search objects using the {@link #getSearch(String)} method. - */ -// Since this was created we have added Application, and much of the content in this should probably migrate there. -public class SearchBuilder { - - private final DocumentTypeManager docTypeMgr = new DocumentTypeManager(); - private final DocumentModel model = new DocumentModel(); - private final Application application; - private final QueryProfileRegistry queryProfileRegistry; - private final FileRegistry fileRegistry; - private final DeployLogger deployLogger; - private final ModelContext.Properties properties; - /** True to build the document aspect only, skipping instantiation of rank profiles */ - private final boolean documentsOnly; - - private List schemaList = new LinkedList<>(); - private boolean isBuilt = false; - - private final Set> processorsToSkip = new HashSet<>(); - - /** For testing only */ - public SearchBuilder() { - this(new RankProfileRegistry(), new QueryProfileRegistry()); - } - - /** For testing only */ - public SearchBuilder(DeployLogger deployLogger) { - this(MockApplicationPackage.createEmpty(), deployLogger); - } - - /** For testing only */ - public SearchBuilder(DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry) { - this(MockApplicationPackage.createEmpty(), deployLogger, rankProfileRegistry); - } - - /** Used for generating documents for typed access to document fields in Java */ - public SearchBuilder(boolean documentsOnly) { - this(MockApplicationPackage.createEmpty(), new MockFileRegistry(), new BaseDeployLogger(), new TestProperties(), new RankProfileRegistry(), new QueryProfileRegistry(), documentsOnly); - } - - /** For testing only */ - public SearchBuilder(ApplicationPackage app, DeployLogger deployLogger) { - this(app, new MockFileRegistry(), deployLogger, new TestProperties(), new RankProfileRegistry(), new QueryProfileRegistry()); - } - - /** For testing only */ - public SearchBuilder(ApplicationPackage app, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry) { - this(app, new MockFileRegistry(), deployLogger, new TestProperties(), rankProfileRegistry, new QueryProfileRegistry()); - } - - /** For testing only */ - public SearchBuilder(RankProfileRegistry rankProfileRegistry) { - this(rankProfileRegistry, new QueryProfileRegistry()); - } - - /** For testing only */ - public SearchBuilder(RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfileRegistry) { - this(rankProfileRegistry, queryProfileRegistry, new TestProperties()); - } - public SearchBuilder(RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfileRegistry, ModelContext.Properties properties) { - this(MockApplicationPackage.createEmpty(), new MockFileRegistry(), new BaseDeployLogger(), properties, rankProfileRegistry, queryProfileRegistry); - } - - public SearchBuilder(ApplicationPackage app, - FileRegistry fileRegistry, - DeployLogger deployLogger, - ModelContext.Properties properties, - RankProfileRegistry rankProfileRegistry, - QueryProfileRegistry queryProfileRegistry) { - this(app, fileRegistry, deployLogger, properties, rankProfileRegistry, queryProfileRegistry, false); - } - private SearchBuilder(ApplicationPackage applicationPackage, - FileRegistry fileRegistry, - DeployLogger deployLogger, - ModelContext.Properties properties, - RankProfileRegistry rankProfileRegistry, - QueryProfileRegistry queryProfileRegistry, - boolean documentsOnly) { - this.application = new Application(applicationPackage, rankProfileRegistry); - this.queryProfileRegistry = queryProfileRegistry; - this.fileRegistry = fileRegistry; - this.deployLogger = deployLogger; - this.properties = properties; - this.documentsOnly = documentsOnly; - } - - /** - * Import search definition. - * - * @param fileName the name of the file to import - * @return the name of the imported object - * @throws IOException thrown if the file can not be read for some reason - * @throws ParseException thrown if the file does not contain a valid search definition - */ - public String importFile(String fileName) throws IOException, ParseException { - File file = new File(fileName); - return importString(IOUtils.readFile(file), file.getAbsoluteFile().getParent()); - } - - private String importFile(Path file) throws IOException, ParseException { - return importFile(file.toString()); - } - - /** - * Reads and parses the search definition string provided by the given reader. Once all search definitions have been - * imported, call {@link #build()}. - * - * @param reader the reader whose content to import - * @param searchDefDir the path to use when resolving file references - * @return the name of the imported object - * @throws ParseException thrown if the file does not contain a valid search definition - */ - public String importReader(NamedReader reader, String searchDefDir) throws IOException, ParseException { - return importString(IOUtils.readAll(reader), searchDefDir); - } - - /** - * Import search definition. - * - * @param str the string to parse. - * @return the name of the imported object. - * @throws ParseException thrown if the file does not contain a valid search definition. - */ - public String importString(String str) throws ParseException { - return importString(str, null); - } - - private String importString(String str, String searchDefDir) throws ParseException { - SimpleCharStream stream = new SimpleCharStream(str); - try { - return importRawSearch(new SDParser(stream, fileRegistry, deployLogger, properties, application, - application.rankProfileRegistry(), documentsOnly) - .schema(docTypeMgr, searchDefDir)); - } catch (TokenMgrException e) { - throw new ParseException("Unknown symbol: " + e.getMessage()); - } catch (ParseException pe) { - throw new ParseException(stream.formatException(Exceptions.toMessageString(pe))); - } - } - - /** - * Registers the given search object to the internal list of objects to be processed during {@link #build()}. A - * {@link Schema} object is considered to be "raw" if it has not already been processed. This is the case for most - * programmatically constructed search objects used in unit tests. - * - * @param schema the object to import. - * @return the name of the imported object. - * @throws IllegalArgumentException if the given search object has already been processed. - */ - public String importRawSearch(Schema schema) { - if (schema.getName() == null) - throw new IllegalArgumentException("Schema has no name"); - String rawName = schema.getName(); - application.add(schema); - schemaList.add(schema); - return rawName; - } - - /** - * Only for testing. - * - * Processes and finalizes the imported search definitions so that they become available through the {@link - * #getSearch(String)} method. - * - * @throws IllegalStateException Thrown if this method has already been called. - */ - public void build() { - build(true); - } - - /** - * Processes and finalizes the imported search definitions so that they become available through the {@link - * #getSearch(String)} method. - * - * @throws IllegalStateException Thrown if this method has already been called. - */ - public void build(boolean validate) { - if (isBuilt) throw new IllegalStateException("Model already built"); - - if (validate) - application.validate(deployLogger); - - List built = new ArrayList<>(); - List sdocs = new ArrayList<>(); - sdocs.add(SDDocumentType.VESPA_DOCUMENT); - for (Schema schema : schemaList) { - if (schema.hasDocument()) { - sdocs.add(schema.getDocument()); - } - } - - var orderer = new SDDocumentTypeOrderer(sdocs, deployLogger); - orderer.process(); - for (SDDocumentType sdoc : orderer.getOrdered()) { - new FieldOperationApplierForStructs().process(sdoc); - new FieldOperationApplier().process(sdoc); - } - - var resolver = new DocumentReferenceResolver(schemaList); - sdocs.forEach(resolver::resolveReferences); - sdocs.forEach(resolver::resolveInheritedReferences); - var importedFieldsEnumerator = new ImportedFieldsEnumerator(schemaList); - sdocs.forEach(importedFieldsEnumerator::enumerateImportedFields); - - if (validate) - new DocumentGraphValidator().validateDocumentGraph(sdocs); - - var builder = new DocumentModelBuilder(model); - for (Schema schema : new SearchOrderer().order(schemaList)) { - new FieldOperationApplierForSearch().process(schema); // TODO: Why is this not in the regular list? - process(schema, new QueryProfiles(queryProfileRegistry, deployLogger), validate); - built.add(schema); - } - builder.addToModel(schemaList); - - if ( validate && ! builder.valid() ) - throw new IllegalArgumentException("Impossible to build a correct model"); - - schemaList = built; - isBuilt = true; - } - - /** Returns a modifiable set of processors we should skip for these schemas. Useful for testing. */ - public Set> processorsToSkip() { return processorsToSkip; } - - /** - * Processes and returns the given {@link Schema} object. This method has been factored out of the {@link - * #build()} method so that subclasses can choose not to build anything. - */ - private void process(Schema schema, QueryProfiles queryProfiles, boolean validate) { - new Processing().process(schema, deployLogger, application.rankProfileRegistry(), queryProfiles, validate, - documentsOnly, processorsToSkip); - } - - /** - * Convenience method to call {@link #getSearch(String)} when there is only a single {@link Schema} object - * built. This method will never return null. - * - * @return the built object - * @throws IllegalStateException if there is not exactly one search. - */ - public Schema getSearch() { - if ( ! isBuilt) throw new IllegalStateException("Searches not built."); - if (application.schemas().size() != 1) - throw new IllegalStateException("This call only works if we have 1 schema. Schemas: " + - application.schemas().values()); - - return application.schemas().values().stream().findAny().get(); - } - - public DocumentModel getModel() { - return model; - } - - /** - * Returns the built {@link Schema} object that has the given name. If the name is unknown, this method will simply - * return null. - * - * @param name the name of the search definition to return, - * or null to return the only one or throw an exception if there are multiple to choose from - * @return the built object, or null if none with this name - * @throws IllegalStateException if {@link #build()} has not been called. - */ - public Schema getSearch(String name) { - if ( ! isBuilt) throw new IllegalStateException("Searches not built."); - if (name == null) return getSearch(); - return application.schemas().get(name); - } - - public Application application() { return application; } - - /** - * Convenience method to return a list of all built {@link Schema} objects. - * - * @return the list of built searches - */ - public List getSearchList() { - return new ArrayList<>(schemaList); - } - - /** - * Convenience factory method to import and build a {@link Schema} object from a string. - * - * @param sd The string to build from. - * @return The built {@link SearchBuilder} object. - * @throws ParseException Thrown if there was a problem parsing the string. - */ - public static SearchBuilder createFromString(String sd) throws ParseException { - return createFromString(sd, new BaseDeployLogger()); - } - - public static SearchBuilder createFromString(String sd, DeployLogger logger) throws ParseException { - SearchBuilder builder = new SearchBuilder(logger); - builder.importString(sd); - builder.build(true); - return builder; - } - - public static SearchBuilder createFromStrings(DeployLogger logger, String ... schemas) throws ParseException { - SearchBuilder builder = new SearchBuilder(logger); - for (var schema : schemas) - builder.importString(schema); - builder.build(true); - return builder; - } - - /** - * Convenience factory method to import and build a {@link Schema} object from a file. Only for testing. - * - * @param fileName the file to build from - * @return the built {@link SearchBuilder} object - * @throws IOException if there was a problem reading the file. - * @throws ParseException if there was a problem parsing the file content. - */ - public static SearchBuilder createFromFile(String fileName) throws IOException, ParseException { - return createFromFile(fileName, new BaseDeployLogger()); - } - - /** - * Convenience factory methdd to create a SearchBuilder from multiple SD files. Only for testing. - */ - public static SearchBuilder createFromFiles(Collection fileNames) throws IOException, ParseException { - return createFromFiles(fileNames, new BaseDeployLogger()); - } - - public static SearchBuilder createFromFile(String fileName, DeployLogger logger) throws IOException, ParseException { - return createFromFile(fileName, logger, new RankProfileRegistry(), new QueryProfileRegistry()); - } - - private static SearchBuilder createFromFiles(Collection fileNames, DeployLogger logger) throws IOException, ParseException { - return createFromFiles(fileNames, new MockFileRegistry(), logger, new TestProperties(), new RankProfileRegistry(), new QueryProfileRegistry()); - } - - /** - * Convenience factory method to import and build a {@link Schema} object from a file. - * - * @param fileName the file to build from. - * @param deployLogger logger for deploy messages. - * @param rankProfileRegistry registry for rank profiles. - * @return the built {@link SearchBuilder} object. - * @throws IOException if there was a problem reading the file. - * @throws ParseException if there was a problem parsing the file content. - */ - private static SearchBuilder createFromFile(String fileName, - DeployLogger deployLogger, - RankProfileRegistry rankProfileRegistry, - QueryProfileRegistry queryprofileRegistry) - throws IOException, ParseException { - return createFromFiles(Collections.singletonList(fileName), new MockFileRegistry(), deployLogger, new TestProperties(), - rankProfileRegistry, queryprofileRegistry); - } - - /** - * Convenience factory methdd to create a SearchBuilder from multiple SD files.. - */ - private static SearchBuilder createFromFiles(Collection fileNames, - FileRegistry fileRegistry, - DeployLogger deployLogger, - ModelContext.Properties properties, - RankProfileRegistry rankProfileRegistry, - QueryProfileRegistry queryprofileRegistry) - throws IOException, ParseException { - SearchBuilder builder = new SearchBuilder(MockApplicationPackage.createEmpty(), - fileRegistry, - deployLogger, - properties, - rankProfileRegistry, - queryprofileRegistry); - for (String fileName : fileNames) { - builder.importFile(fileName); - } - builder.build(true); - return builder; - } - - - public static SearchBuilder createFromDirectory(String dir, FileRegistry fileRegistry, DeployLogger logger, ModelContext.Properties properties) throws IOException, ParseException { - return createFromDirectory(dir, fileRegistry, logger, properties, new RankProfileRegistry()); - } - public static SearchBuilder createFromDirectory(String dir, - FileRegistry fileRegistry, - DeployLogger logger, - ModelContext.Properties properties, - RankProfileRegistry rankProfileRegistry) throws IOException, ParseException { - return createFromDirectory(dir, fileRegistry, logger, properties, rankProfileRegistry, createQueryProfileRegistryFromDirectory(dir)); - } - private static SearchBuilder createFromDirectory(String dir, - FileRegistry fileRegistry, - DeployLogger logger, - ModelContext.Properties properties, - RankProfileRegistry rankProfileRegistry, - QueryProfileRegistry queryProfileRegistry) throws IOException, ParseException { - return createFromDirectory(dir, MockApplicationPackage.fromSearchDefinitionAndRootDirectory(dir), fileRegistry, logger, properties, - rankProfileRegistry, queryProfileRegistry); - } - - private static SearchBuilder createFromDirectory(String dir, - ApplicationPackage applicationPackage, - FileRegistry fileRegistry, - DeployLogger deployLogger, - ModelContext.Properties properties, - RankProfileRegistry rankProfileRegistry, - QueryProfileRegistry queryProfileRegistry) throws IOException, ParseException { - SearchBuilder builder = new SearchBuilder(applicationPackage, - fileRegistry, - deployLogger, - properties, - rankProfileRegistry, - queryProfileRegistry); - for (Iterator i = Files.list(new File(dir).toPath()).filter(p -> p.getFileName().toString().endsWith(".sd")).iterator(); i.hasNext(); ) { - builder.importFile(i.next()); - } - builder.build(true); - return builder; - } - - private static QueryProfileRegistry createQueryProfileRegistryFromDirectory(String dir) { - File queryProfilesDir = new File(dir, "query-profiles"); - if ( ! queryProfilesDir.exists()) return new QueryProfileRegistry(); - return new QueryProfileXMLReader().read(queryProfilesDir.toString()); - } - - // TODO: The build methods below just call the create methods above - remove - - /** - * Convenience factory method to import and build a {@link Schema} object from a file. Only for testing. - * - * @param fileName The file to build from. - * @return The built {@link Schema} object. - * @throws IOException Thrown if there was a problem reading the file. - * @throws ParseException Thrown if there was a problem parsing the file content. - */ - public static Schema buildFromFile(String fileName) throws IOException, ParseException { - return buildFromFile(fileName, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfileRegistry()); - } - - /** - * Convenience factory method to import and build a {@link Schema} object from a file. - * - * @param fileName The file to build from. - * @param rankProfileRegistry Registry for rank profiles. - * @return The built {@link Schema} object. - * @throws IOException Thrown if there was a problem reading the file. - * @throws ParseException Thrown if there was a problem parsing the file content. - */ - public static Schema buildFromFile(String fileName, - RankProfileRegistry rankProfileRegistry, - QueryProfileRegistry queryProfileRegistry) - throws IOException, ParseException { - return buildFromFile(fileName, new BaseDeployLogger(), rankProfileRegistry, queryProfileRegistry); - } - - /** - * Convenience factory method to import and build a {@link Schema} object from a file. - * - * @param fileName The file to build from. - * @param deployLogger Logger for deploy messages. - * @param rankProfileRegistry Registry for rank profiles. - * @return The built {@link Schema} object. - * @throws IOException Thrown if there was a problem reading the file. - * @throws ParseException Thrown if there was a problem parsing the file content. - */ - public static Schema buildFromFile(String fileName, - DeployLogger deployLogger, - RankProfileRegistry rankProfileRegistry, - QueryProfileRegistry queryProfileRegistry) - throws IOException, ParseException { - return createFromFile(fileName, deployLogger, rankProfileRegistry, queryProfileRegistry).getSearch(); - } - - /** - * Convenience factory method to import and build a {@link Schema} object from a raw object. - * - * @param rawSchema the raw object to build from. - * @return the built {@link SearchBuilder} object. - * @see #importRawSearch(Schema) - */ - public static SearchBuilder createFromRawSearch(Schema rawSchema, - RankProfileRegistry rankProfileRegistry, - QueryProfileRegistry queryProfileRegistry) { - SearchBuilder builder = new SearchBuilder(rankProfileRegistry, queryProfileRegistry); - builder.importRawSearch(rawSchema); - builder.build(); - return builder; - } - - /** - * Convenience factory method to import and build a {@link Schema} object from a raw object. - * - * @param rawSchema The raw object to build from. - * @return The built {@link Schema} object. - * @see #importRawSearch(Schema) - */ - public static Schema buildFromRawSearch(Schema rawSchema, - RankProfileRegistry rankProfileRegistry, - QueryProfileRegistry queryProfileRegistry) { - return createFromRawSearch(rawSchema, rankProfileRegistry, queryProfileRegistry).getSearch(); - } - - public RankProfileRegistry getRankProfileRegistry() { - return application.rankProfileRegistry(); - } - - public QueryProfileRegistry getQueryProfileRegistry() { - return queryProfileRegistry; - } - public ModelContext.Properties getProperties() { return properties; } - public DeployLogger getDeployLogger() { return deployLogger; } - -} diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/Deriver.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/Deriver.java index 24221d2ed75..10dca70ab6c 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/Deriver.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/Deriver.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.document.DocumenttypesConfig; import com.yahoo.document.config.DocumentmanagerConfig; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.configmodel.producers.DocumentManager; import com.yahoo.vespa.configmodel.producers.DocumentTypes; @@ -17,8 +17,8 @@ import java.util.List; */ public class Deriver { - public static SearchBuilder getSearchBuilder(List sds) { - SearchBuilder builder = new SearchBuilder(); + public static SchemaBuilder getSearchBuilder(List sds) { + SchemaBuilder builder = new SchemaBuilder(); try { for (String s : sds) { builder.importFile(s); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/ArraysTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/ArraysTestCase.java index 131c6e19c68..aaf75f0c852 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/ArraysTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/ArraysTestCase.java @@ -22,7 +22,7 @@ public class ArraysTestCase extends AbstractSchemaTestCase { @Test public void testArrayImporting() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/arrays.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/arrays.sd"); SDField tags = (SDField) schema.getDocument().getField("tags"); assertEquals(DataType.STRING, ((CollectionDataType)tags.getDataType()).getNestedType()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/ArraysWeightedSetsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/ArraysWeightedSetsTestCase.java index 0d5a4b357b1..1dd2c987d90 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/ArraysWeightedSetsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/ArraysWeightedSetsTestCase.java @@ -19,7 +19,7 @@ import static org.junit.Assert.assertTrue; public class ArraysWeightedSetsTestCase extends AbstractSchemaTestCase { @Test public void testArrayWeightedSetsImporting() throws java.io.IOException, com.yahoo.searchdefinition.parser.ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/arraysweightedsets.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/arraysweightedsets.sd"); SDField tags = (SDField) schema.getDocument().getField("tags"); assertTrue(tags.getDataType() instanceof ArrayDataType); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java index b891fc97924..d1179451308 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/AttributeSettingsTestCase.java @@ -32,7 +32,7 @@ public class AttributeSettingsTestCase extends AbstractSchemaTestCase { @Test public void testAttributeSettings() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/attributesettings.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/attributesettings.sd"); SDField f1=(SDField) schema.getDocument().getField("f1"); assertEquals(1, f1.getAttributes().size()); @@ -93,7 +93,7 @@ public class AttributeSettingsTestCase extends AbstractSchemaTestCase { @Test public void requireThatFastAccessCanBeSet() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/attributesettings.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/attributesettings.sd"); SDField field = (SDField) schema.getDocument().getField("fast_access"); assertEquals(1, field.getAttributes().size()); Attribute attr = field.getAttributes().get(field.getName()); @@ -101,7 +101,7 @@ public class AttributeSettingsTestCase extends AbstractSchemaTestCase { } private Schema getSearch(String sd) throws ParseException { - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); builder.importString(sd); builder.build(); return builder.getSearch(); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/CommentTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/CommentTestCase.java index 35eccb19151..8b7f0885907 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/CommentTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/CommentTestCase.java @@ -18,7 +18,7 @@ public class CommentTestCase extends AbstractSchemaTestCase { @Test public void testComments() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/comment.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/comment.sd"); SDField field = schema.getConcreteField("a"); assertEquals("{ input a | tokenize normalize stem:\"BEST\" | summary a | index a; }", field.getIndexingScript().toString()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/DiversityTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/DiversityTestCase.java index e6191772904..58cdbdc1bf9 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/DiversityTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/DiversityTestCase.java @@ -15,7 +15,7 @@ public class DiversityTestCase { @Test public void testDiversity() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + @@ -60,7 +60,7 @@ public class DiversityTestCase { } @Test public void requireSingleNumericOrString() throws ParseException { - SearchBuilder builder = getSearchBuilder("field b type predicate { indexing: attribute }"); + SchemaBuilder builder = getSearchBuilder("field b type predicate { indexing: attribute }"); try { builder.build(); @@ -72,7 +72,7 @@ public class DiversityTestCase { @Test public void requireSingle() throws ParseException { - SearchBuilder builder = getSearchBuilder("field b type array { indexing: attribute }"); + SchemaBuilder builder = getSearchBuilder("field b type array { indexing: attribute }"); try { builder.build(); @@ -81,9 +81,9 @@ public class DiversityTestCase { assertEquals(getMessagePrefix() + "must be single value numeric, or enumerated attribute, but it is 'Array'", e.getMessage()); } } - private SearchBuilder getSearchBuilder(String diversity) throws ParseException { + private SchemaBuilder getSearchBuilder(String diversity) throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectRankingExpressionFileRefTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectRankingExpressionFileRefTestCase.java index aab8c9939d2..621e7061203 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectRankingExpressionFileRefTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectRankingExpressionFileRefTestCase.java @@ -21,7 +21,7 @@ public class IncorrectRankingExpressionFileRefTestCase extends AbstractSchemaTes public void testIncorrectRef() throws IOException, ParseException { try { RankProfileRegistry registry = new RankProfileRegistry(); - Schema schema = SearchBuilder.buildFromFile("src/test/examples/incorrectrankingexpressionfileref.sd", + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/incorrectrankingexpressionfileref.sd", registry, new QueryProfileRegistry()); new DerivedConfiguration(schema, registry); // cause rank profile parsing diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectSummaryTypesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectSummaryTypesTestCase.java index 76f8c05c1c8..55593ef64e4 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectSummaryTypesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/IncorrectSummaryTypesTestCase.java @@ -15,7 +15,7 @@ public class IncorrectSummaryTypesTestCase extends AbstractSchemaTestCase { @Test public void testImportingIncorrect() throws ParseException { try { - SearchBuilder.createFromString( + SchemaBuilder.createFromString( "search incorrectsummarytypes {\n" + " document incorrectsummarytypes {\n" + " field somestring type string {\n" + diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/IndexSettingsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/IndexSettingsTestCase.java index 0e25798fbe2..2107781b5fa 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/IndexSettingsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/IndexSettingsTestCase.java @@ -21,7 +21,7 @@ public class IndexSettingsTestCase extends AbstractSchemaTestCase { @Test public void testStemmingSettings() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/indexsettings.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/indexsettings.sd"); SDField usingDefault=(SDField) schema.getDocument().getField("usingdefault"); assertEquals(Stemming.SHORTEST,usingDefault.getStemming(schema)); @@ -38,7 +38,7 @@ public class IndexSettingsTestCase extends AbstractSchemaTestCase { @Test public void requireThatInterlavedFeaturesAreSetOnExtraField() throws ParseException { - SearchBuilder builder = SearchBuilder.createFromString(joinLines( + SchemaBuilder builder = SchemaBuilder.createFromString(joinLines( "search test {", " document test {", " field content type string {", diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/IndexingParsingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/IndexingParsingTestCase.java index 428114f47e5..60728ab7d99 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/IndexingParsingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/IndexingParsingTestCase.java @@ -15,13 +15,13 @@ public class IndexingParsingTestCase extends AbstractSchemaTestCase { @Test public void requireThatIndexingExpressionsCanBeParsed() throws Exception { - assertNotNull(SearchBuilder.buildFromFile("src/test/examples/indexing.sd")); + assertNotNull(SchemaBuilder.buildFromFile("src/test/examples/indexing.sd")); } @Test public void requireThatParseExceptionPositionIsCorrect() throws Exception { try { - SearchBuilder.buildFromFile("src/test/examples/indexing_invalid_expression.sd"); + SchemaBuilder.buildFromFile("src/test/examples/indexing_invalid_expression.sd"); } catch (ParseException e) { if (!e.getMessage().contains("at line 5, column 57.")) { throw e; diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/MultipleSummariesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/MultipleSummariesTestCase.java index 181f12083c4..41321b5c81e 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/MultipleSummariesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/MultipleSummariesTestCase.java @@ -14,6 +14,6 @@ import java.io.IOException; public class MultipleSummariesTestCase extends AbstractSchemaTestCase { @Test public void testArrayImporting() throws IOException, ParseException { - SearchBuilder.buildFromFile("src/test/examples/multiplesummaries.sd"); + SchemaBuilder.buildFromFile("src/test/examples/multiplesummaries.sd"); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/NameFieldCheckTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/NameFieldCheckTestCase.java index 46da671d860..fc94bbe8731 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/NameFieldCheckTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/NameFieldCheckTestCase.java @@ -19,7 +19,7 @@ public class NameFieldCheckTestCase extends AbstractSchemaTestCase { @Test public void testNameField() { try { - SearchBuilder.createFromString( + SchemaBuilder.createFromString( "search simple {\n" + " document name-check {\n" + " field title type string {\n" + @@ -40,7 +40,7 @@ public class NameFieldCheckTestCase extends AbstractSchemaTestCase { @Test public void testDuplicateNamesInSearchDifferentType() { try { - SearchBuilder.createFromString( + SchemaBuilder.createFromString( "search duplicatenamesinsearch {\n" + " document {\n" + " field grpphotoids64 type string { }\n" + @@ -60,7 +60,7 @@ public class NameFieldCheckTestCase extends AbstractSchemaTestCase { @Test public void testDuplicateNamesInDoc() { try { - SearchBuilder.createFromString( + SchemaBuilder.createFromString( "search duplicatenamesindoc {\n" + " document {\n" + " field foo type int {\n" + diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/OutsideTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/OutsideTestCase.java index fda1f184a62..5663473481b 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/OutsideTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/OutsideTestCase.java @@ -17,7 +17,7 @@ public class OutsideTestCase extends AbstractSchemaTestCase { @Test public void testOutsideIndex() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/outsidedoc.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/outsidedoc.sd"); Index defaultIndex= schema.getIndex("default"); assertTrue(defaultIndex.isPrefix()); @@ -26,7 +26,7 @@ public class OutsideTestCase extends AbstractSchemaTestCase { @Test public void testOutsideSummary() throws IOException, ParseException { - SearchBuilder.buildFromFile("src/test/examples/outsidesummary.sd"); + SchemaBuilder.buildFromFile("src/test/examples/outsidesummary.sd"); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/PredicateDataTypeTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/PredicateDataTypeTestCase.java index e5afb481b80..a41d4388bce 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/PredicateDataTypeTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/PredicateDataTypeTestCase.java @@ -64,7 +64,7 @@ public class PredicateDataTypeTestCase { lowerBoundParameter(lowerBound) + upperBoundParameter(upperBound)))); - SearchBuilder sb = SearchBuilder.createFromString(sd); + SchemaBuilder sb = SchemaBuilder.createFromString(sd); for (ImmutableSDField field : sb.getSearch().allConcreteFields()) { if (field.getDataType() == DataType.PREDICATE) { for (Index index : field.getIndices().values()) { @@ -91,7 +91,7 @@ public class PredicateDataTypeTestCase { "lower-bound: -100000000000000000L\n" + // +'L' upperBoundParameter(upperBound)))); - SearchBuilder sb = SearchBuilder.createFromString(sd); + SchemaBuilder sb = SchemaBuilder.createFromString(sd); for (ImmutableSDField field : sb.getSearch().allConcreteFields()) { if (field.getDataType() == DataType.PREDICATE) { for (Index index : field.getIndices().values()) { @@ -109,7 +109,7 @@ public class PredicateDataTypeTestCase { predicateFieldSd( attributeFieldSd( arityParameter(2)))); - SearchBuilder sb = SearchBuilder.createFromString(sd); + SchemaBuilder sb = SchemaBuilder.createFromString(sd); for (ImmutableSDField field : sb.getSearch().allConcreteFields()) { if (field.getDataType() == DataType.PREDICATE) { for (Index index : field.getIndices().values()) { @@ -127,7 +127,7 @@ public class PredicateDataTypeTestCase { exception.expect(IllegalArgumentException.class); exception.expectMessage("Missing arity value in predicate field."); - SearchBuilder.createFromString(sd); + SchemaBuilder.createFromString(sd); fail(); } @@ -137,7 +137,7 @@ public class PredicateDataTypeTestCase { exception.expect(IllegalArgumentException.class); exception.expectMessage("For schema 'p', field 'pf': Use 'attribute' instead of 'index'. This will require a refeed if you have upgraded."); - SearchBuilder.createFromString(sd); + SchemaBuilder.createFromString(sd); } @Test @@ -146,7 +146,7 @@ public class PredicateDataTypeTestCase { exception.expect(IllegalArgumentException.class); exception.expectMessage("For schema 'p', field 'pf': Use 'attribute' instead of 'index'. This will require a refeed if you have upgraded."); - SearchBuilder.createFromString(sd); + SchemaBuilder.createFromString(sd); } @@ -156,7 +156,7 @@ public class PredicateDataTypeTestCase { exception.expect(IllegalArgumentException.class); exception.expectMessage("Invalid arity value in predicate field, must be greater than 1."); - SearchBuilder.createFromString(sd); + SchemaBuilder.createFromString(sd); } @Test @@ -165,7 +165,7 @@ public class PredicateDataTypeTestCase { exception.expect(IllegalArgumentException.class); exception.expectMessage("Arity parameter is used only for predicate type fields."); - SearchBuilder.createFromString(sd); + SchemaBuilder.createFromString(sd); } @Test @@ -177,7 +177,7 @@ public class PredicateDataTypeTestCase { exception.expect(IllegalArgumentException.class); exception.expectMessage("Parameters lower-bound and upper-bound are used only for predicate type fields."); - SearchBuilder.createFromString(sd); + SchemaBuilder.createFromString(sd); } @Test @@ -189,7 +189,7 @@ public class PredicateDataTypeTestCase { exception.expect(IllegalArgumentException.class); exception.expectMessage("Collections of predicates are not allowed."); - SearchBuilder.createFromString(sd); + SchemaBuilder.createFromString(sd); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java index 857da3068cd..ed82d2335bf 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankProfileTestCase.java @@ -69,7 +69,7 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { public void requireThatIllegalInheritanceIsChecked() throws ParseException { try { RankProfileRegistry registry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(registry, setupQueryProfileTypes()); + SchemaBuilder builder = new SchemaBuilder(registry, setupQueryProfileTypes()); builder.importString(joinLines( "search test {", " document test { } ", @@ -86,7 +86,7 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { public void requireThatSelfInheritanceIsIllegal() throws ParseException { try { RankProfileRegistry registry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(registry, setupQueryProfileTypes()); + SchemaBuilder builder = new SchemaBuilder(registry, setupQueryProfileTypes()); builder.importString(joinLines( "schema test {", " document test { } ", @@ -102,7 +102,7 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { @Test public void requireThatSelfInheritanceIsLegalWhenOverloading() throws ParseException { RankProfileRegistry registry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(registry, setupQueryProfileTypes()); + SchemaBuilder builder = new SchemaBuilder(registry, setupQueryProfileTypes()); builder.importString(joinLines( "schema base {", " document base { } ", @@ -119,7 +119,7 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { @Test public void requireThatSidewaysInheritanceIsImpossible() throws ParseException { RankProfileRegistry registry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(registry, setupQueryProfileTypes()); + SchemaBuilder builder = new SchemaBuilder(registry, setupQueryProfileTypes()); builder.importString(joinLines( "schema child1 {", " document child1 {", @@ -172,7 +172,7 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { @Test public void requireThatDefaultCanAlwaysBeInherited() throws ParseException { RankProfileRegistry registry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(registry, setupQueryProfileTypes()); + SchemaBuilder builder = new SchemaBuilder(registry, setupQueryProfileTypes()); builder.importString(joinLines( "schema test {", " document test { } ", @@ -185,7 +185,7 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { public void requireThatCyclicInheritanceIsIllegal() throws ParseException { try { RankProfileRegistry registry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(registry, setupQueryProfileTypes()); + SchemaBuilder builder = new SchemaBuilder(registry, setupQueryProfileTypes()); builder.importString(joinLines( "search test {", " document test { } ", @@ -204,7 +204,7 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { public void requireThatRankProfilesCanInheritNotYetSeenProfiles() throws ParseException { RankProfileRegistry registry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(registry, setupQueryProfileTypes()); + SchemaBuilder builder = new SchemaBuilder(registry, setupQueryProfileTypes()); builder.importString(joinLines( "search test {", " document test { } ", @@ -246,7 +246,7 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { private void verifyTermwiseLimitAndSomeMoreIncludingInheritance(ModelContext.Properties deployProperties, String sd, Double termwiseLimit) throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString(sd); builder.build(); Schema schema = builder.getSearch(); @@ -279,7 +279,7 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { @Test public void requireThatConfigIsDerivedForAttributeTypeSettings() throws ParseException { RankProfileRegistry registry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(registry); + SchemaBuilder builder = new SchemaBuilder(registry); builder.importString(joinLines( "search test {", " document test { ", @@ -303,7 +303,7 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { @Test public void requireThatDenseDimensionsMustBeBound() throws ParseException { try { - SearchBuilder builder = new SearchBuilder(new RankProfileRegistry()); + SchemaBuilder builder = new SchemaBuilder(new RankProfileRegistry()); builder.importString(joinLines( "search test {", " document test { ", @@ -332,7 +332,7 @@ public class RankProfileTestCase extends AbstractSchemaTestCase { @Test public void requireThatConfigIsDerivedForQueryFeatureTypeSettings() throws ParseException { RankProfileRegistry registry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(registry, setupQueryProfileTypes()); + SchemaBuilder builder = new SchemaBuilder(registry, setupQueryProfileTypes()); builder.importString(joinLines( "search test {", " document test { } ", diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java index 637f7571a68..0d940ed30bd 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankPropertiesTestCase.java @@ -23,7 +23,7 @@ public class RankPropertiesTestCase extends AbstractSchemaTestCase { @Test public void testRankPropertyInheritance() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString(joinLines( "search test {", " document test {", @@ -80,7 +80,7 @@ public class RankPropertiesTestCase extends AbstractSchemaTestCase { @Test public void testRankProfileMutate() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString(joinLines( "search test {", " document test {", diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingConstantTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingConstantTest.java index 8bfd9c898e4..4f4a8db18c4 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingConstantTest.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingConstantTest.java @@ -27,8 +27,8 @@ public class RankingConstantTest { final String TENSOR_FILE = "path/my-tensor-file.json"; final String TENSOR_TYPE = "tensor(x{})"; RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder searchBuilder = new SearchBuilder(rankProfileRegistry); - searchBuilder.importString(joinLines( + SchemaBuilder schemaBuilder = new SchemaBuilder(rankProfileRegistry); + schemaBuilder.importString(joinLines( "search test {", " document test { }", " rank-profile my_rank_profile {", @@ -42,8 +42,8 @@ public class RankingConstantTest { " }", "}" )); - searchBuilder.build(); - Schema schema = searchBuilder.getSearch(); + schemaBuilder.build(); + Schema schema = schemaBuilder.getSearch(); Iterator constantIterator = schema.rankingConstants().asMap().values().iterator(); RankingConstant constant = constantIterator.next(); @@ -58,10 +58,10 @@ public class RankingConstantTest { @Test public void tensor_constant_must_have_a_type() throws Exception { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder searchBuilder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder schemaBuilder = new SchemaBuilder(rankProfileRegistry); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("must have a type"); - searchBuilder.importString(joinLines( + schemaBuilder.importString(joinLines( "search test {", " document test { }", " constant foo {", @@ -74,10 +74,10 @@ public class RankingConstantTest { @Test public void tensor_constant_must_have_a_file() throws Exception { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder searchBuilder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder schemaBuilder = new SchemaBuilder(rankProfileRegistry); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("must have a file"); - searchBuilder.importString(joinLines( + schemaBuilder.importString(joinLines( "search test {", " document test { }", " constant foo {", @@ -90,8 +90,8 @@ public class RankingConstantTest { @Test public void constant_file_does_not_need_path_or_ending() throws Exception { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder searchBuilder = new SearchBuilder(rankProfileRegistry); - searchBuilder.importString(joinLines( + SchemaBuilder schemaBuilder = new SchemaBuilder(rankProfileRegistry); + schemaBuilder.importString(joinLines( "search test {", " document test { }", " constant foo {", @@ -100,8 +100,8 @@ public class RankingConstantTest { " }", "}" )); - searchBuilder.build(); - Schema schema = searchBuilder.getSearch(); + schemaBuilder.build(); + Schema schema = schemaBuilder.getSearch(); RankingConstant constant = schema.rankingConstants().asMap().values().iterator().next(); assertEquals("simplename", constant.getFileName()); } @@ -109,8 +109,8 @@ public class RankingConstantTest { @Test public void constant_uri_is_allowed() throws Exception { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder searchBuilder = new SearchBuilder(rankProfileRegistry); - searchBuilder.importString(joinLines( + SchemaBuilder schemaBuilder = new SchemaBuilder(rankProfileRegistry); + schemaBuilder.importString(joinLines( "search test {", " document test { }", " constant foo {", @@ -119,8 +119,8 @@ public class RankingConstantTest { " }", "}" )); - searchBuilder.build(); - Schema schema = searchBuilder.getSearch(); + schemaBuilder.build(); + Schema schema = schemaBuilder.getSearch(); RankingConstant constant = schema.rankingConstants().asMap().values().iterator().next(); assertEquals(RankingConstant.PathType.URI, constant.getPathType()); assertEquals("http://somewhere.far.away/in/another-galaxy", constant.getUri()); @@ -129,8 +129,8 @@ public class RankingConstantTest { @Test public void constant_https_uri_is_allowed() throws Exception { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder searchBuilder = new SearchBuilder(rankProfileRegistry); - searchBuilder.importString(joinLines( + SchemaBuilder schemaBuilder = new SchemaBuilder(rankProfileRegistry); + schemaBuilder.importString(joinLines( "search test {", " document test { }", " constant foo {", @@ -139,8 +139,8 @@ public class RankingConstantTest { " }", "}" )); - searchBuilder.build(); - Schema schema = searchBuilder.getSearch(); + schemaBuilder.build(); + Schema schema = schemaBuilder.getSearch(); RankingConstant constant = schema.rankingConstants().asMap().values().iterator().next(); assertEquals(RankingConstant.PathType.URI, constant.getPathType()); assertEquals("https://somewhere.far.away:4443/in/another-galaxy", constant.getUri()); @@ -149,8 +149,8 @@ public class RankingConstantTest { @Test public void constant_uri_with_port_is_allowed() throws Exception { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder searchBuilder = new SearchBuilder(rankProfileRegistry); - searchBuilder.importString(joinLines( + SchemaBuilder schemaBuilder = new SchemaBuilder(rankProfileRegistry); + schemaBuilder.importString(joinLines( "search test {", " document test { }", " constant foo {", @@ -159,8 +159,8 @@ public class RankingConstantTest { " }", "}" )); - searchBuilder.build(); - Schema schema = searchBuilder.getSearch(); + schemaBuilder.build(); + Schema schema = schemaBuilder.getSearch(); RankingConstant constant = schema.rankingConstants().asMap().values().iterator().next(); assertEquals(RankingConstant.PathType.URI, constant.getPathType()); assertEquals("http://somewhere.far.away:4080/in/another-galaxy", constant.getUri()); @@ -169,8 +169,8 @@ public class RankingConstantTest { @Test public void constant_uri_no_dual_slashes_is_allowed() throws Exception { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder searchBuilder = new SearchBuilder(rankProfileRegistry); - searchBuilder.importString(joinLines( + SchemaBuilder schemaBuilder = new SchemaBuilder(rankProfileRegistry); + schemaBuilder.importString(joinLines( "search test {", " document test { }", " constant foo {", @@ -179,8 +179,8 @@ public class RankingConstantTest { " }", "}" )); - searchBuilder.build(); - Schema schema = searchBuilder.getSearch(); + schemaBuilder.build(); + Schema schema = schemaBuilder.getSearch(); RankingConstant constant = schema.rankingConstants().asMap().values().iterator().next(); assertEquals(RankingConstant.PathType.URI, constant.getPathType()); assertEquals("http:somewhere.far.away/in/another-galaxy", constant.getUri()); @@ -189,12 +189,12 @@ public class RankingConstantTest { @Test public void constant_uri_only_supports_http_and_https() { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder searchBuilder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder schemaBuilder = new SchemaBuilder(rankProfileRegistry); String expectedMessage = "Encountered \" \"ftp\"\" at line 5, column 10.\n\n" + "Was expecting:\n\n" + " ..."; try { - searchBuilder.importString(joinLines( + schemaBuilder.importString(joinLines( "search test {", " document test { }", " constant foo {", diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionConstantsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionConstantsTestCase.java index 19a50817f75..988aec84eac 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionConstantsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionConstantsTestCase.java @@ -25,7 +25,7 @@ public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { public void testConstants() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); QueryProfileRegistry queryProfileRegistry = new QueryProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + @@ -91,7 +91,7 @@ public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { @Test public void testNameCollision() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + @@ -125,7 +125,7 @@ public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { @Test public void testNegativeLiteralArgument() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + @@ -150,7 +150,7 @@ public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { @Test public void testNegativeConstantArgument() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + @@ -180,7 +180,7 @@ public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { @Test public void testConstantDivisorInFunction() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + @@ -203,7 +203,7 @@ public class RankingExpressionConstantsTestCase extends AbstractSchemaTestCase { @Test public void test3() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java index 238e71a6340..9baa655befc 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionInliningTestCase.java @@ -28,7 +28,7 @@ public class RankingExpressionInliningTestCase extends AbstractSchemaTestCase { @Test public void testFunctionInliningPreserveArithmeticOrdering() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + @@ -79,7 +79,7 @@ public class RankingExpressionInliningTestCase extends AbstractSchemaTestCase { @Test public void testConstants() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + @@ -150,7 +150,7 @@ public class RankingExpressionInliningTestCase extends AbstractSchemaTestCase { @Test public void testNonTopLevelInlining() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + @@ -194,7 +194,7 @@ public class RankingExpressionInliningTestCase extends AbstractSchemaTestCase { public void testFunctionInliningWithReplacement() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); MockDeployLogger deployLogger = new MockDeployLogger(); - SearchBuilder builder = new SearchBuilder(MockApplicationPackage.createEmpty(), + SchemaBuilder builder = new SchemaBuilder(MockApplicationPackage.createEmpty(), new MockFileRegistry(), deployLogger, new TestProperties(), diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionLoopDetectionTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionLoopDetectionTestCase.java index fff5c2023b9..689b75690ae 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionLoopDetectionTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionLoopDetectionTestCase.java @@ -16,7 +16,7 @@ public class RankingExpressionLoopDetectionTestCase { @Test public void testSelfLoop() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + @@ -48,7 +48,7 @@ public class RankingExpressionLoopDetectionTestCase { @Test public void testNestedLoop() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + @@ -83,7 +83,7 @@ public class RankingExpressionLoopDetectionTestCase { @Test public void testSelfArgumentLoop() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + @@ -118,7 +118,7 @@ public class RankingExpressionLoopDetectionTestCase { @Test public void testNoLoopWithSameLocalArgument() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + @@ -146,7 +146,7 @@ public class RankingExpressionLoopDetectionTestCase { @Test public void testNoLoopWithMultipleInvocations() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + @@ -174,7 +174,7 @@ public class RankingExpressionLoopDetectionTestCase { @Test public void testNoLoopWithBoundIdentifiers() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + @@ -197,7 +197,7 @@ public class RankingExpressionLoopDetectionTestCase { @Test public void testNoLoopWithTheSameNestedIdentifierWhichIsUnbound() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + @@ -220,7 +220,7 @@ public class RankingExpressionLoopDetectionTestCase { @Test public void testNoLoopWithTheSameAlternatingNestedIdentifierWhichIsUnbound() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java index 231fa531770..8cea119be11 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionShadowingTestCase.java @@ -26,7 +26,7 @@ public class RankingExpressionShadowingTestCase extends AbstractSchemaTestCase { @Test public void testBasicFunctionShadowing() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + @@ -61,7 +61,7 @@ public class RankingExpressionShadowingTestCase extends AbstractSchemaTestCase { @Test public void testMultiLevelFunctionShadowing() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + @@ -113,7 +113,7 @@ public class RankingExpressionShadowingTestCase extends AbstractSchemaTestCase { @Test public void testFunctionShadowingArguments() throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + @@ -153,7 +153,7 @@ public class RankingExpressionShadowingTestCase extends AbstractSchemaTestCase { // Note: the type assigned to query profile and constant tensors here is not the correct type RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); QueryProfileRegistry queryProfiles = queryProfileWith("query(q)", "tensor(input[1])"); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry, queryProfiles); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry, queryProfiles); builder.importString( "search test {\n" + " document test { \n" + diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionValidationTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionValidationTestCase.java index a66a4cd8648..64873a76179 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionValidationTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/RankingExpressionValidationTestCase.java @@ -32,7 +32,7 @@ public class RankingExpressionValidationTestCase extends AbstractSchemaTestCase } private Schema importWithExpression(String expression, RankProfileRegistry registry) throws ParseException { - SearchBuilder builder = new SearchBuilder(registry); + SchemaBuilder builder = new SchemaBuilder(registry); builder.importString("search test {" + " document test { " + " field a type string { " + diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/ReservedWordsAsFieldNamesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/ReservedWordsAsFieldNamesTestCase.java index f893f532f09..a6f76897c0b 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/ReservedWordsAsFieldNamesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/ReservedWordsAsFieldNamesTestCase.java @@ -15,7 +15,7 @@ public class ReservedWordsAsFieldNamesTestCase extends AbstractSchemaTestCase { @Test public void testIt() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/reserved_words_as_field_names.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/reserved_words_as_field_names.sd"); assertNotNull(schema.getDocument().getField("inline")); assertNotNull(schema.getDocument().getField("constants")); assertNotNull(schema.getDocument().getField("reference")); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/SchemaImporterTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/SchemaImporterTestCase.java index 1ae44e30c32..e26b588c74e 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/SchemaImporterTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/SchemaImporterTestCase.java @@ -36,7 +36,7 @@ public class SchemaImporterTestCase extends AbstractSchemaTestCase { @SuppressWarnings("deprecation") public void testSimpleImporting() throws IOException, ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder sb = new SearchBuilder(rankProfileRegistry, new QueryProfileRegistry()); + SchemaBuilder sb = new SchemaBuilder(rankProfileRegistry, new QueryProfileRegistry()); sb.importFile("src/test/examples/simple.sd"); sb.build(); Schema schema = sb.getSearch(); @@ -170,7 +170,7 @@ public class SchemaImporterTestCase extends AbstractSchemaTestCase { public void testDocumentImporting() throws IOException, ParseException { try { // Having two documents in one sd-file is illegal. - SearchBuilder.buildFromFile("src/test/examples/documents.sd"); + SchemaBuilder.buildFromFile("src/test/examples/documents.sd"); fail(); } catch (IllegalArgumentException e) { } @@ -178,7 +178,7 @@ public class SchemaImporterTestCase extends AbstractSchemaTestCase { @Test public void testIdImporting() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/strange.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/strange.sd"); SDField idecidemyide=(SDField) schema.getDocument().getField("idecidemyide"); assertEquals(5,idecidemyide.getId()); SDField sodoi=(SDField) schema.getDocument().getField("sodoi"); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/SchemaParsingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/SchemaParsingTestCase.java index 984140be12c..dfe60c5871e 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/SchemaParsingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/SchemaParsingTestCase.java @@ -19,13 +19,13 @@ public class SchemaParsingTestCase extends AbstractSchemaTestCase { @Test public void requireThatIndexingExpressionsCanBeParsed() throws Exception { - assertNotNull(SearchBuilder.buildFromFile("src/test/examples/simple.sd")); + assertNotNull(SchemaBuilder.buildFromFile("src/test/examples/simple.sd")); } @Test public void requireThatParseExceptionPositionIsCorrect() throws Exception { try { - SearchBuilder.buildFromFile("src/test/examples/invalid_sd_construct.sd"); + SchemaBuilder.buildFromFile("src/test/examples/invalid_sd_construct.sd"); } catch (ParseException e) { if ( ! e.getMessage().contains("at line 5, column 36.")) { throw e; @@ -36,7 +36,7 @@ public class SchemaParsingTestCase extends AbstractSchemaTestCase { @Test public void requireThatParserHandlesLexicalError() throws Exception { try { - SearchBuilder.buildFromFile("src/test/examples/invalid_sd_lexical_error.sd"); + SchemaBuilder.buildFromFile("src/test/examples/invalid_sd_lexical_error.sd"); } catch (ParseException e) { if (!e.getMessage().contains("at line 7, column 27.")) { throw e; @@ -47,7 +47,7 @@ public class SchemaParsingTestCase extends AbstractSchemaTestCase { @Test public void requireErrorWhenJunkAfterSearchBlock() throws IOException, ParseException { try { - SearchBuilder.buildFromFile("src/test/examples/invalid_sd_junk_at_end.sd"); + SchemaBuilder.buildFromFile("src/test/examples/invalid_sd_junk_at_end.sd"); fail("Illegal junk at end of SD passed"); } catch (ParseException e) { if (!e.getMessage().contains("at line 10, column 1")) { @@ -59,7 +59,7 @@ public class SchemaParsingTestCase extends AbstractSchemaTestCase { @Test public void requireErrorWhenMissingClosingSearchBracket() throws IOException, ParseException { try { - SearchBuilder.buildFromFile("src/test/examples/invalid_sd_no_closing_bracket.sd"); + SchemaBuilder.buildFromFile("src/test/examples/invalid_sd_no_closing_bracket.sd"); fail("SD without closing bracket passed"); } catch (ParseException e) { if (!e.getMessage().contains("Encountered \"\" at line 8, column 1")) { @@ -71,7 +71,7 @@ public class SchemaParsingTestCase extends AbstractSchemaTestCase { @Test public void illegalSearchDefinitionName() throws IOException, ParseException { try { - SearchBuilder.buildFromFile("src/test/examples/invalid-name.sd"); + SchemaBuilder.buildFromFile("src/test/examples/invalid-name.sd"); fail("Name with dash passed"); } catch (ParseException e) { if ( ! e.getMessage().contains("invalid-name")) { @@ -83,7 +83,7 @@ public class SchemaParsingTestCase extends AbstractSchemaTestCase { // TODO: Remove in Vespa 8 @Test public void requireThatParserHandlesHeadAndBody() throws IOException, ParseException { - assertNotNull(SearchBuilder.buildFromFile("src/test/examples/header_body.sd")); + assertNotNull(SchemaBuilder.buildFromFile("src/test/examples/header_body.sd")); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/SchemaTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/SchemaTestCase.java index 8b96779f695..3413fe3c373 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/SchemaTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/SchemaTestCase.java @@ -30,7 +30,7 @@ public class SchemaTestCase { " }" + "}"); DeployLoggerStub logger = new DeployLoggerStub(); - SearchBuilder.createFromStrings(logger, schema); + SchemaBuilder.createFromStrings(logger, schema); assertEquals("schema 'test' inherits 'nonesuch', but this schema does not exist", logger.entries.get(0).message); fail("Expected failure"); @@ -59,7 +59,7 @@ public class SchemaTestCase { " }" + " }" + "}"); - SearchBuilder.createFromStrings(new DeployLoggerStub(), parent, child); + SchemaBuilder.createFromStrings(new DeployLoggerStub(), parent, child); } catch (IllegalArgumentException e) { assertEquals("schema 'child' inherits 'parent', " + @@ -135,7 +135,7 @@ public class SchemaTestCase { "}"); System.out.println(parentLines); - SearchBuilder builder = new SearchBuilder(new DeployLoggerStub()); + SchemaBuilder builder = new SchemaBuilder(new DeployLoggerStub()); builder.processorsToSkip().add(OnnxModelTypeResolver.class); // Avoid discovering the Onnx model referenced does not exist builder.processorsToSkip().add(ImportedFieldsResolver.class); // Avoid discovering the document reference leads nowhere builder.importString(parentLines); @@ -230,7 +230,7 @@ public class SchemaTestCase { " }" + "}"); - SearchBuilder builder = new SearchBuilder(new DeployLoggerStub()); + SchemaBuilder builder = new SchemaBuilder(new DeployLoggerStub()); builder.processorsToSkip().add(OnnxModelTypeResolver.class); // Avoid discovering the Onnx model referenced does not exist builder.processorsToSkip().add(ImportedFieldsResolver.class); // Avoid discovering the document reference leads nowhere builder.importString(parentLines); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/StemmingSettingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/StemmingSettingTestCase.java index d382e29ca4d..75dcd6bc209 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/StemmingSettingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/StemmingSettingTestCase.java @@ -20,7 +20,7 @@ public class StemmingSettingTestCase extends AbstractSchemaTestCase { @Test public void testStemmingSettings() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/stemmingsetting.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/stemmingsetting.sd"); SDField artist = (SDField) schema.getDocument().getField("artist"); assertEquals(Stemming.SHORTEST, artist.getStemming(schema)); @@ -43,7 +43,7 @@ public class StemmingSettingTestCase extends AbstractSchemaTestCase { @Test public void requireThatStemmingIsDefaultBest() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/stemmingdefault.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/stemmingdefault.sd"); assertNull(schema.getConcreteField("my_str").getStemming()); assertEquals(Stemming.BEST, schema.getConcreteField("my_str").getStemming(schema)); } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java index b86225110df..0c305df7e53 100755 --- a/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java @@ -25,7 +25,7 @@ public class StructTestCase extends AbstractSchemaTestCase { @Test public void testBadStruct() throws IOException { try { - SearchBuilder.buildFromFile("src/test/examples/badstruct.sd"); + SchemaBuilder.buildFromFile("src/test/examples/badstruct.sd"); fail("Should throw exception."); } catch (ParseException expected) { // success @@ -46,7 +46,7 @@ public class StructTestCase extends AbstractSchemaTestCase { */ @Test(expected = IllegalArgumentException.class) public void testStructOutsideDocumentIllegal() throws IOException, ParseException { - SearchBuilder.buildFromFile("src/test/examples/structoutsideofdocument.sd"); + SchemaBuilder.buildFromFile("src/test/examples/structoutsideofdocument.sd"); } } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/SummaryTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/SummaryTestCase.java index dee63f04ad5..22079b740a3 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/SummaryTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/SummaryTestCase.java @@ -39,7 +39,7 @@ public class SummaryTestCase { " }", "}"); DeployLoggerStub logger = new DeployLoggerStub(); - SearchBuilder.createFromString(sd, logger); + SchemaBuilder.createFromString(sd, logger); assertTrue(logger.entries.isEmpty()); } @@ -61,7 +61,7 @@ public class SummaryTestCase { " }", "}"); DeployLoggerStub logger = new DeployLoggerStub(); - SearchBuilder.createFromString(sd, logger); + SchemaBuilder.createFromString(sd, logger); assertEquals(1, logger.entries.size()); assertEquals(Level.WARNING, logger.entries.get(0).level); assertEquals("summary field 'foo2' in document summary 'foobar' references source field 'ondisk', " + @@ -89,7 +89,7 @@ public class SummaryTestCase { " }", "}"); DeployLoggerStub logger = new DeployLoggerStub(); - SearchBuilder.createFromString(sd, logger); + SchemaBuilder.createFromString(sd, logger); assertTrue(logger.entries.isEmpty()); } @@ -120,7 +120,7 @@ public class SummaryTestCase { " }", "}"); DeployLoggerStub logger = new DeployLoggerStub(); - SearchBuilder.createFromString(sd, logger); + SchemaBuilder.createFromString(sd, logger); assertTrue(logger.entries.isEmpty()); } @@ -156,7 +156,7 @@ public class SummaryTestCase { " }", "}"); var logger = new DeployLoggerStub(); - var search = SearchBuilder.createFromString(sd, logger).getSearch(); + var search = SchemaBuilder.createFromString(sd, logger).getSearch(); assertEquals(List.of(), logger.entries); var titleField = "title"; @@ -208,7 +208,7 @@ public class SummaryTestCase { "}"); var logger = new DeployLoggerStub(); try { - SearchBuilder.createFromString(sd, logger); + SchemaBuilder.createFromString(sd, logger); fail("Expected exception"); } catch (IllegalArgumentException e) { assertEquals("For schema 'music', summary class 'title2', summary field 'title': Can not use " + @@ -228,7 +228,7 @@ public class SummaryTestCase { " }" + "}"); DeployLoggerStub logger = new DeployLoggerStub(); - SearchBuilder.createFromStrings(logger, schema); + SchemaBuilder.createFromStrings(logger, schema); assertEquals("document summary 'test_summary' inherits nonesuch but this is not present in schema 'test'", logger.entries.get(0).message); // fail("Expected failure"); @@ -264,7 +264,7 @@ public class SummaryTestCase { " }" + "}"); DeployLoggerStub logger = new DeployLoggerStub(); - SearchBuilder.createFromStrings(logger, parent, child); + SchemaBuilder.createFromStrings(logger, parent, child); logger.entries.forEach(e -> System.out.println(e)); //assertTrue(logger.entries.isEmpty()); } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/UrlFieldValidationTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/UrlFieldValidationTestCase.java index 8873fc36303..9fdeb9ece1d 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/UrlFieldValidationTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/UrlFieldValidationTestCase.java @@ -15,7 +15,7 @@ public class UrlFieldValidationTestCase { @Test public void requireThatInheritedRiseFieldsStillCanBeInConflictButDontThrowException() throws ParseException { - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); builder.importString("search test {" + " document test { " + " field a type uri { indexing: attribute | summary }" + diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java index 9ba9f3b37f7..b452d5b883d 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java @@ -8,7 +8,7 @@ import com.yahoo.config.model.deploy.TestProperties; import com.yahoo.document.DocumenttypesConfig; import com.yahoo.document.config.DocumentmanagerConfig; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import ai.vespa.rankingexpression.importer.configmodelview.ImportedMlModels; @@ -36,14 +36,14 @@ public abstract class AbstractExportingTestCase extends AbstractSchemaTestCase { toDir.mkdirs(); deleteContent(toDir); - SearchBuilder builder = SearchBuilder.createFromDirectory(searchDefRoot + dirName + "/", new MockFileRegistry(), logger, properties); + SchemaBuilder builder = SchemaBuilder.createFromDirectory(searchDefRoot + dirName + "/", new MockFileRegistry(), logger, properties); return derive(dirName, searchDefinitionName, properties, builder, logger); } private DerivedConfiguration derive(String dirName, String searchDefinitionName, TestProperties properties, - SearchBuilder builder, + SchemaBuilder builder, DeployLogger logger) throws IOException { DerivedConfiguration config = new DerivedConfiguration(builder.getSearch(searchDefinitionName), logger, @@ -55,14 +55,14 @@ public abstract class AbstractExportingTestCase extends AbstractSchemaTestCase { return export(dirName, builder, config); } - DerivedConfiguration derive(String dirName, SearchBuilder builder, Schema schema) throws IOException { + DerivedConfiguration derive(String dirName, SchemaBuilder builder, Schema schema) throws IOException { DerivedConfiguration config = new DerivedConfiguration(schema, builder.getRankProfileRegistry(), builder.getQueryProfileRegistry()); return export(dirName, builder, config); } - private DerivedConfiguration export(String name, SearchBuilder builder, DerivedConfiguration config) throws IOException { + private DerivedConfiguration export(String name, SchemaBuilder builder, DerivedConfiguration config) throws IOException { String path = exportConfig(name, config); DerivedConfiguration.exportDocuments(new DocumentManager().produce(builder.getModel(), new DocumentmanagerConfig.Builder()), path); DerivedConfiguration.exportDocuments(new DocumentTypes().produce(builder.getModel(), new DocumenttypesConfig.Builder()), path); @@ -111,14 +111,14 @@ public abstract class AbstractExportingTestCase extends AbstractSchemaTestCase { * Asserts config is correctly derived given a builder. * This will fail if the builder contains multiple search definitions. */ - protected DerivedConfiguration assertCorrectDeriving(SearchBuilder builder, String dirName, DeployLogger logger) throws IOException { + protected DerivedConfiguration assertCorrectDeriving(SchemaBuilder builder, String dirName, DeployLogger logger) throws IOException { builder.build(); DerivedConfiguration derived = derive(dirName, null, new TestProperties(), builder, logger); assertCorrectConfigFiles(dirName); return derived; } - protected DerivedConfiguration assertCorrectDeriving(SearchBuilder builder, Schema schema, String name) throws IOException { + protected DerivedConfiguration assertCorrectDeriving(SchemaBuilder builder, Schema schema, String name) throws IOException { DerivedConfiguration derived = derive(name, builder, schema); assertCorrectConfigFiles(name); return derived; diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java index f8316c831f1..fd22338f6ea 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AttributeListTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.parser.ParseException; @@ -25,7 +25,7 @@ public class AttributeListTestCase extends AbstractSchemaTestCase { @Test public void testDeriving() throws IOException, ParseException { // Test attribute importing - Schema schema = SearchBuilder.buildFromFile("src/test/examples/simple.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/simple.sd"); // Test attribute deriving AttributeFields attributeFields = new AttributeFields(schema); @@ -71,7 +71,7 @@ public class AttributeListTestCase extends AbstractSchemaTestCase { @Test public void fields_in_array_of_struct_are_derived_into_array_attributes() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/derived/array_of_struct_attribute/test.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/derived/array_of_struct_attribute/test.sd"); Iterator attributes = new AttributeFields(schema).attributeIterator(); assertAttribute("elem_array.name", Attribute.Type.STRING, Attribute.CollectionType.ARRAY, true, attributes.next()); @@ -81,7 +81,7 @@ public class AttributeListTestCase extends AbstractSchemaTestCase { @Test public void fields_in_map_of_struct_are_derived_into_array_attributes() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/derived/map_of_struct_attribute/test.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/derived/map_of_struct_attribute/test.sd"); Iterator attributes = new AttributeFields(schema).attributeIterator(); assertAttribute("str_elem_map.key", Attribute.Type.STRING, Attribute.CollectionType.ARRAY, true, attributes.next()); @@ -101,7 +101,7 @@ public class AttributeListTestCase extends AbstractSchemaTestCase { @Test public void only_zcurve_attribute_is_derived_from_array_of_position_field() throws ParseException { - Schema schema = SearchBuilder.createFromString( + Schema schema = SchemaBuilder.createFromString( joinLines("search test {", " document test {", " field pos_array type array {", @@ -117,7 +117,7 @@ public class AttributeListTestCase extends AbstractSchemaTestCase { @Test public void fields_in_map_of_primitive_are_derived_into_array_attributes() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/derived/map_attribute/test.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/derived/map_attribute/test.sd"); Iterator attributes = new AttributeFields(schema).attributeIterator(); assertAttribute("str_map.key", Attribute.Type.STRING, Attribute.CollectionType.ARRAY, true, attributes.next()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/CasingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/CasingTestCase.java index 080752d260f..06d72bb6972 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/CasingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/CasingTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -20,7 +20,7 @@ public class CasingTestCase extends AbstractSchemaTestCase { @Test public void testCasing() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/casing.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/casing.sd"); assertEquals(schema.getIndex("color").getName(), "color"); assertEquals(schema.getIndex("Foo").getName(), "Foo"); assertEquals(schema.getIndex("Price").getName(), "Price"); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/EmptyRankProfileTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/EmptyRankProfileTestCase.java index 2633f7881bd..4235e1e6f4e 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/EmptyRankProfileTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/EmptyRankProfileTestCase.java @@ -5,7 +5,7 @@ import com.yahoo.document.DataType; import com.yahoo.search.query.profile.QueryProfileRegistry; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; @@ -30,7 +30,7 @@ public class EmptyRankProfileTestCase extends AbstractSchemaTestCase { doc.addField(field); doc.addField(new SDField("c", DataType.STRING)); - schema = SearchBuilder.buildFromRawSearch(schema, rankProfileRegistry, new QueryProfileRegistry()); + schema = SchemaBuilder.buildFromRawSearch(schema, rankProfileRegistry, new QueryProfileRegistry()); new DerivedConfiguration(schema, rankProfileRegistry); } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/ExportingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/ExportingTestCase.java index 867b88019d5..311332571cc 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/ExportingTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/ExportingTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.config.model.deploy.TestProperties; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -146,7 +146,7 @@ public class ExportingTestCase extends AbstractExportingTestCase { @Test public void testTensor2() throws IOException, ParseException { String dir = "src/test/derived/tensor2/"; - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); builder.importFile(dir + "first.sd"); builder.importFile(dir + "second.sd"); builder.build(); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/InheritanceTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/InheritanceTestCase.java index 59950cee638..b183ccbd320 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/InheritanceTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/InheritanceTestCase.java @@ -5,7 +5,7 @@ import com.yahoo.document.DataType; import com.yahoo.document.config.DocumentmanagerConfig; import com.yahoo.searchdefinition.Index; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.parser.ParseException; @@ -37,7 +37,7 @@ public class InheritanceTestCase extends AbstractExportingTestCase { @Test public void requireThatIndexedStructFieldCanBeInherited() throws IOException, ParseException { String dir = "src/test/derived/inheritstruct/"; - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); builder.importFile(dir + "parent.sd"); builder.importFile(dir + "child.sd"); builder.build(); @@ -60,7 +60,7 @@ public class InheritanceTestCase extends AbstractExportingTestCase { List files = Arrays.asList("grandparent.sd", "mother.sd", "father.sd", "child.sd"); File outDir = tmpDir.newFolder("out"); for (int startIdx = 0; startIdx < files.size(); ++startIdx) { - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); for (int fileIdx = startIdx; fileIdx < startIdx + files.size(); ++fileIdx) { String fileName = files.get(fileIdx % files.size()); builder.importFile(dir + fileName); @@ -107,7 +107,7 @@ public class InheritanceTestCase extends AbstractExportingTestCase { @Test public void requireThatStructTypesAreInheritedFromParent() throws IOException, ParseException { String dir = "src/test/derived/inheritfromparent/"; - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); builder.importFile(dir + "parent.sd"); builder.importFile(dir + "child.sd"); builder.build(); @@ -118,7 +118,7 @@ public class InheritanceTestCase extends AbstractExportingTestCase { @Test public void requireThatStructTypesAreInheritedFromGrandParent() throws IOException, ParseException { String dir = "src/test/derived/inheritfromgrandparent/"; - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); builder.importFile(dir + "grandparent.sd"); builder.importFile(dir + "parent.sd"); builder.importFile(dir + "child.sd"); @@ -130,7 +130,7 @@ public class InheritanceTestCase extends AbstractExportingTestCase { @Test public void testInheritance() throws IOException, ParseException { String dir = "src/test/derived/inheritance/"; - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); builder.importFile(dir + "grandparent.sd"); builder.importFile(dir + "father.sd"); builder.importFile(dir + "mother.sd"); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/LiteralBoostTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/LiteralBoostTestCase.java index 507c5370237..01a39facc16 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/LiteralBoostTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/LiteralBoostTestCase.java @@ -7,7 +7,7 @@ import com.yahoo.search.query.profile.QueryProfileRegistry; import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.processing.Processing; @@ -73,7 +73,7 @@ public class LiteralBoostTestCase extends AbstractExportingTestCase { rankProfileRegistry.add(other); other.addRankSetting(new RankProfile.RankSetting("a", RankProfile.RankSetting.Type.LITERALBOOST, 333)); - schema = SearchBuilder.buildFromRawSearch(schema, rankProfileRegistry, new QueryProfileRegistry()); + schema = SchemaBuilder.buildFromRawSearch(schema, rankProfileRegistry, new QueryProfileRegistry()); DerivedConfiguration derived = new DerivedConfiguration(schema, rankProfileRegistry); // Check il script addition @@ -100,7 +100,7 @@ public class LiteralBoostTestCase extends AbstractExportingTestCase { field2.parseIndexingScript("{ summary | index }"); field2.setLiteralBoost(20); - schema = SearchBuilder.buildFromRawSearch(schema, rankProfileRegistry, new QueryProfileRegistry()); + schema = SchemaBuilder.buildFromRawSearch(schema, rankProfileRegistry, new QueryProfileRegistry()); new DerivedConfiguration(schema, rankProfileRegistry); assertIndexing(Arrays.asList("clear_state | guard { input title | tokenize normalize stem:\"BEST\" | summary title | index title; }", "clear_state | guard { input body | tokenize normalize stem:\"BEST\" | summary body | index body; }", diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/MailTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/MailTestCase.java index 198013b73c0..9ad6dfbb972 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/MailTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/MailTestCase.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.derived; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; import java.io.IOException; @@ -16,7 +16,7 @@ public class MailTestCase extends AbstractExportingTestCase { @Test public void testMail() throws IOException, ParseException { String dir = "src/test/derived/mail/"; - SearchBuilder sb = new SearchBuilder(); + SchemaBuilder sb = new SchemaBuilder(); sb.importFile(dir + "mail.sd"); assertCorrectDeriving(sb, dir, new TestableDeployLogger()); } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SchemaInheritanceTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SchemaInheritanceTestCase.java index 254ed26df36..86f017790ac 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SchemaInheritanceTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SchemaInheritanceTestCase.java @@ -4,8 +4,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.config.model.application.provider.MockFileRegistry; import com.yahoo.config.model.deploy.TestProperties; import com.yahoo.io.IOUtils; -import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -20,7 +19,7 @@ public class SchemaInheritanceTestCase extends AbstractExportingTestCase { @Test public void testIt() throws IOException, ParseException { try { - SearchBuilder builder = SearchBuilder.createFromDirectory("src/test/derived/schemainheritance/", + SchemaBuilder builder = SchemaBuilder.createFromDirectory("src/test/derived/schemainheritance/", new MockFileRegistry(), new TestableDeployLogger(), new TestProperties()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SimpleInheritTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SimpleInheritTestCase.java index 106f5a54cfe..31d22c960da 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SimpleInheritTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SimpleInheritTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -19,7 +19,7 @@ public class SimpleInheritTestCase extends AbstractExportingTestCase { String name = "emptychild"; final String expectedResultsDirName = "src/test/derived/" + name + "/"; - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); builder.importFile(expectedResultsDirName + "parent.sd"); builder.importFile(expectedResultsDirName + "child.sd"); builder.build(); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryMapTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryMapTestCase.java index 92b7184959c..314882cac70 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryMapTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryMapTestCase.java @@ -29,7 +29,7 @@ import static org.junit.Assert.assertTrue; public class SummaryMapTestCase extends AbstractSchemaTestCase { @Test public void testDeriving() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/simple.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/simple.sd"); SummaryMap summaryMap=new SummaryMap(schema); Iterator transforms=summaryMap.resultTransformIterator(); @@ -147,7 +147,7 @@ public class SummaryMapTestCase extends AbstractSchemaTestCase { @Test public void testFailOnSummaryFieldSourceCollision() { try { - SearchBuilder.buildFromFile("src/test/examples/summaryfieldcollision.sd"); + SchemaBuilder.buildFromFile("src/test/examples/summaryfieldcollision.sd"); } catch (Exception e) { assertTrue(e.getMessage().matches(".*equally named field.*")); } @@ -189,7 +189,7 @@ public class SummaryMapTestCase extends AbstractSchemaTestCase { } private Schema buildSearch(String field) throws ParseException { - var builder = new SearchBuilder(new RankProfileRegistry()); + var builder = new SchemaBuilder(new RankProfileRegistry()); builder.importString(joinLines("search test {", " document test {", field, diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryTestCase.java index ea801b54b5c..1dca28bb9b1 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SummaryTestCase.java @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.config.model.application.provider.BaseDeployLogger; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.config.search.SummaryConfig; @@ -35,7 +35,7 @@ public class SummaryTestCase extends AbstractSchemaTestCase { " }", " }", "}"); - Schema schema = SearchBuilder.createFromString(sd).getSearch(); + Schema schema = SchemaBuilder.createFromString(sd).getSearch(); SummaryClass summary = new SummaryClass(schema, schema.getSummary("default"), new BaseDeployLogger()); assertEquals(SummaryClassField.Type.RAW, summary.getField("raw_field").getType()); } @@ -50,14 +50,14 @@ public class SummaryTestCase extends AbstractSchemaTestCase { " }", " }", "}"); - Schema schema = SearchBuilder.createFromString(sd).getSearch(); + Schema schema = SchemaBuilder.createFromString(sd).getSearch(); SummaryClass summary = new SummaryClass(schema, schema.getSummary("default"), new BaseDeployLogger()); assertEquals(SummaryClassField.Type.DATA, summary.getField("raw_field").getType()); } @Test public void testDeriving() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/simple.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/simple.sd"); SummaryClass summary = new SummaryClass(schema, schema.getSummary("default"), new BaseDeployLogger()); assertEquals("default", summary.getName()); @@ -134,7 +134,7 @@ public class SummaryTestCase extends AbstractSchemaTestCase { } private static Schema buildCampaignAdModel() throws ParseException { - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); builder.importString("search campaign { document campaign {} }"); builder.importString(joinLines("search ad {", " document ad {", @@ -168,7 +168,7 @@ public class SummaryTestCase extends AbstractSchemaTestCase { " summary foo type string {}", " }", "}"); - var search = SearchBuilder.createFromString(sd).getSearch(); + var search = SchemaBuilder.createFromString(sd).getSearch(); assertOmitSummaryFeatures(true, search, "bar"); assertOmitSummaryFeatures(false, search, "baz"); } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/TwoStreamingStructsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/TwoStreamingStructsTestCase.java index 8249245cebe..de8ced60917 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/TwoStreamingStructsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/TwoStreamingStructsTestCase.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.derived; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -17,13 +17,13 @@ public class TwoStreamingStructsTestCase extends AbstractExportingTestCase { public void testTwoStreamingStructsExporting() throws ParseException, IOException { String root = "src/test/derived/twostreamingstructs"; - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); builder.importFile(root + "/streamingstruct.sd"); builder.importFile(root + "/whatever.sd"); builder.build(); assertCorrectDeriving(builder, builder.getSearch("streamingstruct"), root); - builder = new SearchBuilder(); + builder = new SchemaBuilder(); builder.importFile(root + "/streamingstruct.sd"); builder.importFile(root + "/whatever.sd"); builder.build(); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/document/ComplexAttributeFieldUtilsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/document/ComplexAttributeFieldUtilsTestCase.java index 449e8054728..d3f991b2f00 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/document/ComplexAttributeFieldUtilsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/document/ComplexAttributeFieldUtilsTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.document; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -17,7 +17,7 @@ public class ComplexAttributeFieldUtilsTestCase { private final ImmutableSDField field; FixtureBase(String fieldName, String sdContent) throws ParseException { - Schema schema = SearchBuilder.createFromString(sdContent).getSearch(); + Schema schema = SchemaBuilder.createFromString(sdContent).getSearch(); field = schema.getConcreteField(fieldName); } diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AssertSearchBuilder.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AssertSearchBuilder.java index d32dd961a85..6a736a5331e 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/AssertSearchBuilder.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/AssertSearchBuilder.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.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.parser.ParseException; import java.io.IOException; @@ -14,13 +14,13 @@ import static org.junit.Assert.*; public abstract class AssertSearchBuilder { public static void assertBuilds(String searchDefinitionFileName) throws IOException, ParseException { - assertNotNull(SearchBuilder.buildFromFile(searchDefinitionFileName)); + assertNotNull(SchemaBuilder.buildFromFile(searchDefinitionFileName)); } public static void assertBuildFails(String searchDefinitionFileName, String expectedException) throws IOException, ParseException { try { - SearchBuilder.buildFromFile(searchDefinitionFileName); + SchemaBuilder.buildFromFile(searchDefinitionFileName); fail(searchDefinitionFileName); } catch (IllegalArgumentException e) { assertEquals(expectedException, e.getMessage()); 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 57e01cb9dfc..f1aa64c1a60 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 @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.Matching; import com.yahoo.searchdefinition.parser.ParseException; @@ -20,7 +20,7 @@ import static org.junit.Assert.assertFalse; public class AttributesExactMatchTestCase extends AbstractSchemaTestCase { @Test public void testAttributesExactMatch() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/attributesexactmatch.sd"); + Schema schema = SchemaBuilder.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); 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 d9d8e47338b..f74e46d92dc 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 @@ -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.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -31,7 +31,7 @@ public class BoldingTestCase extends AbstractSchemaTestCase { @Test public void testBoldOnNonString() throws ParseException { try { - SearchBuilder.createFromString(boldonnonstring); + SchemaBuilder.createFromString(boldonnonstring); fail("Expected exception"); } catch (IllegalArgumentException e) { assertEquals("'bolding: on' for non-text field 'year4' (datatype int (code: 0)) is not allowed", @@ -52,7 +52,7 @@ public class BoldingTestCase extends AbstractSchemaTestCase { @Test public void testBoldOnArray() throws ParseException { try { - SearchBuilder.createFromString(boldonarray); + SchemaBuilder.createFromString(boldonarray); fail("Expected exception"); } catch (IllegalArgumentException e) { assertEquals("'bolding: on' for non-text field 'myarray' (datatype Array (code: -1486737430)) is not allowed", 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 fbfb46be558..342ff4ba2d4 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 @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; -import static com.yahoo.searchdefinition.SearchBuilder.createFromString; +import static com.yahoo.searchdefinition.SchemaBuilder.createFromString; import static com.yahoo.config.model.test.TestUtil.joinLines; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; 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 806b9b3358d..90f15b74881 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 @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.model.test.TestUtil; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.derived.AttributeFields; import com.yahoo.searchdefinition.document.Case; import com.yahoo.searchdefinition.document.Dictionary; @@ -30,7 +30,7 @@ public class DictionaryTestCase { return builder.build(); } private Schema createSearch(String def) throws ParseException { - SearchBuilder sb = SearchBuilder.createFromString(def); + SchemaBuilder sb = SchemaBuilder.createFromString(def); return sb.getSearch(); } @Test @@ -196,7 +196,7 @@ public class DictionaryTestCase { " }", "}"); try { - SearchBuilder sb = SearchBuilder.createFromString(def); + SchemaBuilder sb = SchemaBuilder.createFromString(def); fail("Controlling dictionary for non-numeric fields are not yet supported."); } catch (IllegalArgumentException e) { assertEquals("For schema 'test', field 'n1': You can only specify 'dictionary:' for numeric or string fields", e.getMessage()); @@ -214,7 +214,7 @@ public class DictionaryTestCase { " }", "}"); try { - SearchBuilder sb = SearchBuilder.createFromString(def); + SchemaBuilder sb = SchemaBuilder.createFromString(def); fail("Controlling dictionary for non-fast-search fields are not allowed."); } catch (IllegalArgumentException e) { assertEquals("For schema 'test', field 'n1': You must specify 'attribute:fast-search' to allow dictionary control", e.getMessage()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/DisallowComplexMapAndWsetKeyTypesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/DisallowComplexMapAndWsetKeyTypesTestCase.java index dc6f9b0d6db..03125c48d1d 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/DisallowComplexMapAndWsetKeyTypesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/DisallowComplexMapAndWsetKeyTypesTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -43,7 +43,7 @@ public class DisallowComplexMapAndWsetKeyTypesTestCase { private void testFieldType(String fieldType) throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + 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 0a9807e0746..00f67c80084 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 @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.model.test.TestUtil; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Rule; import org.junit.Test; @@ -19,7 +19,7 @@ public class FastAccessValidatorTest { @Test public void throws_exception_on_incompatible_use_of_fastaccess() throws ParseException { - SearchBuilder builder = new SearchBuilder(new RankProfileRegistry()); + SchemaBuilder builder = new SchemaBuilder(new RankProfileRegistry()); builder.importString( TestUtil.joinLines( "schema parent {", diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSchemaFieldsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSchemaFieldsTestCase.java index dffc0d968df..d57b29418c7 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSchemaFieldsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ImplicitSchemaFieldsTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.derived.DerivedConfiguration; import com.yahoo.searchdefinition.document.SDDocumentType; @@ -18,7 +18,7 @@ public class ImplicitSchemaFieldsTestCase extends AbstractSchemaTestCase { @Test public void testRequireThatExtraFieldsAreIncluded() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/nextgen/extrafield.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/nextgen/extrafield.sd"); assertNotNull(schema); SDDocumentType docType = schema.getDocument(); @@ -30,7 +30,7 @@ public class ImplicitSchemaFieldsTestCase extends AbstractSchemaTestCase { @Test public void testRequireThatSummaryFieldsAreIncluded() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/nextgen/summaryfield.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/nextgen/summaryfield.sd"); assertNotNull(schema); SDDocumentType docType = schema.getDocument(); @@ -43,7 +43,7 @@ public class ImplicitSchemaFieldsTestCase extends AbstractSchemaTestCase { @Test public void testRequireThatBoldedSummaryFieldsAreIncluded() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/nextgen/boldedsummaryfields.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/nextgen/boldedsummaryfields.sd"); assertNotNull(schema); SDDocumentType docType = schema.getDocument(); @@ -57,7 +57,7 @@ public class ImplicitSchemaFieldsTestCase extends AbstractSchemaTestCase { @Test public void testRequireThatUntransformedSummaryFieldsAreIgnored() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/nextgen/untransformedsummaryfields.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/nextgen/untransformedsummaryfields.sd"); assertNotNull(schema); SDDocumentType docType = schema.getDocument(); @@ -70,7 +70,7 @@ public class ImplicitSchemaFieldsTestCase extends AbstractSchemaTestCase { @Test public void testRequireThatDynamicSummaryFieldsAreIgnored() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/nextgen/dynamicsummaryfields.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/nextgen/dynamicsummaryfields.sd"); assertNotNull(schema); SDDocumentType docType = schema.getDocument(); @@ -82,7 +82,7 @@ public class ImplicitSchemaFieldsTestCase extends AbstractSchemaTestCase { @Test public void testRequireThatDerivedConfigurationWorks() throws IOException, ParseException { - SearchBuilder sb = new SearchBuilder(); + SchemaBuilder sb = new SchemaBuilder(); sb.importFile("src/test/examples/nextgen/simple.sd"); sb.build(); assertNotNull(sb.getSearch()); 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 b069f62ee92..bd645b68728 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 @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.document.*; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; @@ -16,7 +16,7 @@ import static org.junit.Assert.*; public class ImplicitStructTypesTestCase extends AbstractSchemaTestCase { @Test public void testRequireThatImplicitStructsAreCreated() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/nextgen/toggleon.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/nextgen/toggleon.sd"); assertNotNull(schema); SDDocumentType docType = schema.getDocument(); @@ -25,7 +25,7 @@ public class ImplicitStructTypesTestCase extends AbstractSchemaTestCase { } @Test public void testRequireThatImplicitStructsAreUsed() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/nextgen/implicitstructtypes.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/nextgen/implicitstructtypes.sd"); assertNotNull(schema); SDDocumentType docType = schema.getDocument(); 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 9f4008b5b39..9c1e5d0d8d7 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 @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.documentmodel.SummaryTransform; import org.junit.Test; @@ -29,7 +29,7 @@ public class ImplicitSummariesTestCase { LogHandler log = new LogHandler(); Logger.getLogger("").addHandler(log); - Schema schema = SearchBuilder.buildFromFile("src/test/examples/implicitsummaries_attribute.sd"); + Schema schema = SchemaBuilder.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 { - Schema schema = SearchBuilder.buildFromFile("src/test/derived/array_of_struct_attribute/test.sd"); + Schema schema = SchemaBuilder.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 { - Schema schema = SearchBuilder.buildFromFile("src/test/derived/map_of_struct_attribute/test.sd"); + Schema schema = SchemaBuilder.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 { - Schema schema = SearchBuilder.buildFromFile("src/test/derived/map_of_struct_attribute/test.sd"); + Schema schema = SchemaBuilder.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 c9f941087ef..44b1d9387f1 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 @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.documentmodel.DocumentSummary; @@ -17,7 +17,7 @@ public class ImplicitSummaryFieldsTestCase extends AbstractSchemaTestCase { @Test public void testRequireThatImplicitFieldsAreCreated() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/implicitsummaryfields.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/implicitsummaryfields.sd"); assertNotNull(schema); DocumentSummary docsum = schema.getSummary("default"); 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 37b7ab0955c..b4f2340c3eb 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 @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.derived.AttributeFields; import com.yahoo.searchdefinition.document.ImportedComplexField; import com.yahoo.searchdefinition.document.ImportedField; @@ -67,7 +67,7 @@ public class ImportedFieldsTestCase { } private static Schema buildAdSearch(String sdContent) throws ParseException { - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); builder.importString(joinLines( "schema campaign {", " document campaign {", @@ -311,7 +311,7 @@ public class ImportedFieldsTestCase { } private static Schema buildChildSearch(String parentSdContent, String sdContent) throws ParseException { - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); builder.importString(parentSdContent); builder.importString(sdContent); builder.build(); @@ -319,7 +319,7 @@ public class ImportedFieldsTestCase { } private static Schema buildChildSearch(String grandParentSdContent, String parentSdContent, String sdContent) throws ParseException { - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); builder.importString(grandParentSdContent); builder.importString(parentSdContent); builder.importString(sdContent); @@ -487,8 +487,8 @@ public class ImportedFieldsTestCase { assertTrue(attrs.containsAttribute("entries.value")); } - private SearchBuilder buildParentsUsingInheritance() throws ParseException { - var builder = new SearchBuilder(); + private SchemaBuilder buildParentsUsingInheritance() throws ParseException { + var builder = new SchemaBuilder(); builder.importString(joinLines("schema parent_a {", "document parent_a {", " struct Entry {", 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 9cbecddfffa..3105e3c7efd 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 @@ -6,7 +6,7 @@ import com.yahoo.document.DataType; import com.yahoo.searchdefinition.Index; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.BooleanIndexDefinition; import com.yahoo.searchdefinition.document.SDDocumentType; @@ -120,7 +120,7 @@ public class IndexingScriptRewriterTestCase extends AbstractSchemaTestCase { "clear_state | guard { input smallattribute | attribute smallattribute; }", "clear_state | guard { input title | tokenize normalize stem:\"BEST\" | summary title | index title; }", "clear_state | guard { input title . \" \" . input category | tokenize | summary exact | index exact; }"), - SearchBuilder.buildFromFile("src/test/examples/simple.sd")); + SchemaBuilder.buildFromFile("src/test/examples/simple.sd")); } @Test @@ -129,7 +129,7 @@ public class IndexingScriptRewriterTestCase extends AbstractSchemaTestCase { Arrays.asList("clear_state | guard { input title_src | lowercase | normalize | " + " tokenize | index title; }", "clear_state | guard { input title_src | summary title_s; }"), - SearchBuilder.buildFromFile("src/test/examples/indexrewrite.sd")); + SchemaBuilder.buildFromFile("src/test/examples/indexrewrite.sd")); } @Test 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 9f8e810f1f8..5b5c5cedc0d 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 @@ -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.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.derived.AbstractExportingTestCase; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -64,7 +64,7 @@ public class IndexingValidationTestCase extends AbstractExportingTestCase { assertIndexing( Arrays.asList("clear_state | guard { input my_index | tokenize normalize stem:\"BEST\" | index my_index | summary my_index }", "clear_state | guard { input my_input | tokenize normalize stem:\"BEST\" | index my_extra | summary my_extra }"), - SearchBuilder.buildFromFile("src/test/examples/indexing_extra.sd")); + SchemaBuilder.buildFromFile("src/test/examples/indexing_extra.sd")); } @Test 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 cd5dd451026..4b13590c777 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 @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.model.application.provider.BaseDeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.parser.ParseException; @@ -24,7 +24,7 @@ public class IntegerIndex2AttributeTestCase extends AbstractSchemaTestCase { @Test public void testIntegerIndex2Attribute() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/integerindex2attribute.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/integerindex2attribute.sd"); new IntegerIndex2Attribute(schema, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles()).process(true, false); SDField f; 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 fc44d61541e..9f5487902a7 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 @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.documentmodel.SummaryField; import com.yahoo.vespa.documentmodel.SummaryTransform; @@ -174,7 +174,7 @@ public class MatchedElementsOnlyResolverTestCase { } private Schema buildSearch(String field, String summary) throws ParseException { - var builder = new SearchBuilder(new RankProfileRegistry()); + var builder = new SchemaBuilder(new RankProfileRegistry()); builder.importString(joinLines("search test {", " document test {", " struct elem {", 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 0e13aacb76f..1adb909ff21 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 @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.document.Matching; import com.yahoo.searchdefinition.document.SDField; @@ -25,7 +25,7 @@ public class NGramTestCase extends AbstractSchemaTestCase { @Test public void testNGram() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/ngram.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/ngram.sd"); assertNotNull(schema); SDField gram1 = schema.getConcreteField("gram_1"); @@ -55,7 +55,7 @@ public class NGramTestCase extends AbstractSchemaTestCase { @Test public void testInvalidNGramSetting1() throws IOException, ParseException { try { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/invalidngram1.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/invalidngram1.sd"); fail("Should cause an exception"); } catch (IllegalArgumentException e) { @@ -66,7 +66,7 @@ public class NGramTestCase extends AbstractSchemaTestCase { @Test public void testInvalidNGramSetting2() throws IOException, ParseException { try { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/invalidngram2.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/invalidngram2.sd"); fail("Should cause an exception"); } catch (IllegalArgumentException e) { @@ -77,7 +77,7 @@ public class NGramTestCase extends AbstractSchemaTestCase { @Test public void testInvalidNGramSetting3() throws IOException, ParseException { try { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/invalidngram3.sd"); + Schema schema = SchemaBuilder.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 360072c1da7..5fce16f381a 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 @@ -5,7 +5,7 @@ import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; import static com.yahoo.config.model.test.TestUtil.joinLines; -import static com.yahoo.searchdefinition.SearchBuilder.createFromString; +import static com.yahoo.searchdefinition.SchemaBuilder.createFromString; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; 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 67e47b7f2ae..d5abe7d04db 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 @@ -5,7 +5,7 @@ import com.yahoo.document.DataType; import com.yahoo.document.DocumentType; import com.yahoo.document.PositionDataType; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.document.FieldSet; import com.yahoo.vespa.documentmodel.SummaryField; @@ -27,7 +27,7 @@ public class PositionTestCase { @Test public void inherited_position_zcurve_field_is_not_added_to_document_fieldset() throws Exception { - SearchBuilder sb = SearchBuilder.createFromFiles(Arrays.asList( + SchemaBuilder sb = SchemaBuilder.createFromFiles(Arrays.asList( "src/test/examples/position_base.sd", "src/test/examples/position_inherited.sd")); @@ -38,7 +38,7 @@ public class PositionTestCase { @Test public void requireThatPositionCanBeAttribute() throws Exception { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/position_attribute.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/position_attribute.sd"); assertNull(schema.getAttribute("pos")); assertNull(schema.getAttribute("pos.x")); assertNull(schema.getAttribute("pos.y")); @@ -50,7 +50,7 @@ public class PositionTestCase { @Test public void requireThatPositionCanNotBeIndex() throws Exception { try { - SearchBuilder.buildFromFile("src/test/examples/position_index.sd"); + SchemaBuilder.buildFromFile("src/test/examples/position_index.sd"); fail(); } catch (IllegalArgumentException e) { assertEquals("For schema 'position_index', field 'pos': Indexing of data type 'position' is not " + @@ -60,7 +60,7 @@ public class PositionTestCase { @Test public void requireThatSummaryAloneDoesNotCreateZCurve() throws Exception { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/position_summary.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/position_summary.sd"); assertNull(schema.getAttribute("pos")); assertNull(schema.getAttribute("pos.x")); assertNull(schema.getAttribute("pos.y")); @@ -79,7 +79,7 @@ public class PositionTestCase { @Test public void requireThatExtraFieldCanBePositionAttribute() throws Exception { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/position_extra.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/position_extra.sd"); assertNull(schema.getAttribute("pos_ext")); assertNull(schema.getAttribute("pos_ext.x")); assertNull(schema.getAttribute("pos_ext.y")); @@ -90,7 +90,7 @@ public class PositionTestCase { @Test public void requireThatPositionArrayIsSupported() throws Exception { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/position_array.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/position_array.sd"); assertNull(schema.getAttribute("pos")); assertNull(schema.getAttribute("pos.x")); assertNull(schema.getAttribute("pos.y")); 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 97eed506c85..87dd92f41d9 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 @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -17,6 +17,6 @@ import java.io.IOException; public class RankModifierTestCase extends AbstractSchemaTestCase { @Test public void testLiteral() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/rankmodifier/literal.sd"); + Schema schema = SchemaBuilder.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 7ffb20859e9..046114bbb43 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 @@ -13,7 +13,7 @@ import com.yahoo.search.query.profile.QueryProfileRegistry; import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.parser.ParseException; import ai.vespa.rankingexpression.importer.configmodelview.ImportedMlModels; import ai.vespa.rankingexpression.importer.onnx.OnnxImporter; @@ -68,7 +68,7 @@ class RankProfileSearchFixture { String rankProfiles, String constant, String field) throws ParseException { this.queryProfileRegistry = queryProfileRegistry; - SearchBuilder builder = new SearchBuilder(applicationpackage, new MockFileRegistry(), new BaseDeployLogger(), new TestProperties(), rankProfileRegistry, queryProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(applicationpackage, new MockFileRegistry(), new BaseDeployLogger(), new TestProperties(), rankProfileRegistry, queryProfileRegistry); String sdContent = "search test {\n" + " " + (constant != null ? constant : "") + "\n" + " document test {\n" + 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 5c53dbf0c57..b1624b7fd7e 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 @@ -6,7 +6,7 @@ import com.yahoo.search.query.profile.QueryProfileRegistry; import com.yahoo.searchdefinition.RankProfile.RankProperty; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -21,7 +21,7 @@ public class RankPropertyVariablesTestCase extends AbstractSchemaTestCase { @Test public void testRankPropVariables() throws IOException, ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - Schema schema = SearchBuilder.buildFromFile("src/test/examples/rankpropvars.sd", + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/rankpropvars.sd", new BaseDeployLogger(), rankProfileRegistry, new QueryProfileRegistry()); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolverTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolverTestCase.java index 3bdcca52236..288078fb2ca 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolverTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolverTestCase.java @@ -7,7 +7,7 @@ import com.yahoo.search.query.profile.types.QueryProfileType; import com.yahoo.search.query.profile.types.TensorFieldType; import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchlib.rankingexpression.rule.ReferenceNode; import com.yahoo.tensor.TensorType; import com.yahoo.yolean.Exceptions; @@ -33,7 +33,7 @@ public class RankingExpressionTypeResolverTestCase { @Test public void tensorFirstPhaseMustProduceDouble() throws Exception { try { - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); builder.importString(joinLines( "search test {", " document test { ", @@ -61,7 +61,7 @@ public class RankingExpressionTypeResolverTestCase { @Test public void tensorFirstPhaseFromConstantMustProduceDouble() throws Exception { try { - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); builder.importString(joinLines( "search test {", " document test { ", @@ -110,7 +110,7 @@ public class RankingExpressionTypeResolverTestCase { @Test public void tensorSecondPhaseMustProduceDouble() throws Exception { try { - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); builder.importString(joinLines( "search test {", " document test { ", @@ -140,8 +140,8 @@ public class RankingExpressionTypeResolverTestCase { @Test public void tensorConditionsMustHaveTypeCompatibleBranches() throws Exception { try { - SearchBuilder searchBuilder = new SearchBuilder(); - searchBuilder.importString(joinLines( + SchemaBuilder schemaBuilder = new SchemaBuilder(); + schemaBuilder.importString(joinLines( "search test {", " document test { ", " field a type tensor(x[10],y[5]) {", @@ -158,7 +158,7 @@ public class RankingExpressionTypeResolverTestCase { " }", "}" )); - searchBuilder.build(); + schemaBuilder.build(); fail("Expected exception"); } catch (IllegalArgumentException expected) { @@ -172,7 +172,7 @@ public class RankingExpressionTypeResolverTestCase { @Test public void testFunctionInvocationTypes() throws Exception { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry); builder.importString(joinLines( "search test {", " document test { ", @@ -205,7 +205,7 @@ public class RankingExpressionTypeResolverTestCase { @Test public void testTensorFunctionInvocationTypes_Nested() throws Exception { - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); builder.importString(joinLines( "search test {", " document test { ", @@ -247,7 +247,7 @@ public class RankingExpressionTypeResolverTestCase { @Test public void testAttributeInvocationViaBoundIdentifier() throws Exception { - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); builder.importString(joinLines( "search newsarticle {", " document newsarticle {", @@ -286,7 +286,7 @@ public class RankingExpressionTypeResolverTestCase { @Test public void testTensorFunctionInvocationTypes_NestedSameName() throws Exception { - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); builder.importString(joinLines( "search test {", " document test { ", @@ -331,7 +331,7 @@ public class RankingExpressionTypeResolverTestCase { @Test public void testTensorFunctionInvocationTypes_viaFuncWithExpr() throws Exception { - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); builder.importString(joinLines( "search test {", " document test {", @@ -353,7 +353,7 @@ public class RankingExpressionTypeResolverTestCase { @Test public void importedFieldsAreAvailable() throws Exception { - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); builder.importString(joinLines( "search parent {", " document parent {", @@ -384,7 +384,7 @@ public class RankingExpressionTypeResolverTestCase { @Test public void undeclaredQueryFeaturesAreAccepted() throws Exception { InspectableDeployLogger logger = new InspectableDeployLogger(); - SearchBuilder builder = new SearchBuilder(logger); + SchemaBuilder builder = new SchemaBuilder(logger); builder.importString(joinLines( "search test {", " document test { ", @@ -410,7 +410,7 @@ public class RankingExpressionTypeResolverTestCase { @Test public void undeclaredQueryFeaturesAreAcceptedWithWarningWhenUsingTensors() throws Exception { InspectableDeployLogger logger = new InspectableDeployLogger(); - SearchBuilder builder = new SearchBuilder(logger); + SchemaBuilder builder = new SchemaBuilder(logger); builder.importString(joinLines( "search test {", " document test { ", @@ -439,7 +439,7 @@ public class RankingExpressionTypeResolverTestCase { @Test public void noWarningWhenUsingTensorsWhenQueryFeaturesAreDeclared() throws Exception { InspectableDeployLogger logger = new InspectableDeployLogger(); - SearchBuilder builder = new SearchBuilder(logger); + SchemaBuilder builder = new SchemaBuilder(logger); QueryProfileType myType = new QueryProfileType("mytype"); myType.addField(new FieldDescription("rank.feature.query(foo)", new TensorFieldType(TensorType.fromSpec("tensor(d[2])"))), 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 e77787e22ca..d02a5422185 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 @@ -9,7 +9,7 @@ import com.yahoo.search.query.profile.QueryProfileRegistry; import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.expressiontransforms.RankProfileTransformContext; import com.yahoo.searchdefinition.expressiontransforms.TokenTransformer; import com.yahoo.searchdefinition.parser.ParseException; @@ -87,10 +87,10 @@ public class RankingExpressionWithTransformerTokensTestCase { " document test {}\n" + " rank-profile my_profile inherits default {}\n" + "}"; - SearchBuilder searchBuilder = new SearchBuilder(application, new MockFileRegistry(), new BaseDeployLogger(), new TestProperties(), rankProfileRegistry, queryProfileRegistry); - searchBuilder.importString(sdContent); - searchBuilder.build(); - Schema schema = searchBuilder.getSearch(); + SchemaBuilder schemaBuilder = new SchemaBuilder(application, new MockFileRegistry(), new BaseDeployLogger(), new TestProperties(), rankProfileRegistry, queryProfileRegistry); + schemaBuilder.importString(sdContent); + schemaBuilder.build(); + Schema schema = schemaBuilder.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 fc5a2b6a39a..7e453aa74dd 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 @@ -11,7 +11,7 @@ import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.AbstractSchemaTestCase; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.derived.DerivedConfiguration; import com.yahoo.searchdefinition.derived.AttributeFields; import com.yahoo.searchdefinition.derived.RawRankProfile; @@ -31,7 +31,7 @@ import static org.junit.Assert.assertTrue; public class RankingExpressionsTestCase extends AbstractSchemaTestCase { 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(); + return SchemaBuilder.createFromDirectory(dir, new MockFileRegistry(), new TestableDeployLogger(), deployProperties, rankProfileRegistry).getSearch(); } @Test 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 41b9d480921..3dcabca4f0f 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 @@ -6,7 +6,7 @@ import com.yahoo.document.Field; import com.yahoo.document.ReferenceDataType; import com.yahoo.searchdefinition.DocumentGraphValidator; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Rule; @@ -28,7 +28,7 @@ public class ReferenceFieldTestCase { @Test public void reference_fields_are_parsed_from_search_definition() throws ParseException { - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); String campaignSdContent = "search campaign {\n" + " document campaign {\n" + @@ -57,7 +57,7 @@ public class ReferenceFieldTestCase { @Test public void cyclic_document_dependencies_are_detected() throws ParseException { - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); String campaignSdContent = "search campaign {\n" + " document campaign {\n" + diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReservedRankingExpressionFunctionNamesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReservedRankingExpressionFunctionNamesTestCase.java index 481acace535..922680e8f1a 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReservedRankingExpressionFunctionNamesTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReservedRankingExpressionFunctionNamesTestCase.java @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -21,7 +21,7 @@ public class ReservedRankingExpressionFunctionNamesTestCase { public void requireThatFunctionsWithReservedNamesIssueAWarning() throws ParseException { TestDeployLogger deployLogger = new TestDeployLogger(); RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - SearchBuilder builder = new SearchBuilder(deployLogger, rankProfileRegistry); + SchemaBuilder builder = new SchemaBuilder(deployLogger, rankProfileRegistry); builder.importString( "search test {\n" + " document test { \n" + diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/SchemaMustHaveDocumentTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/SchemaMustHaveDocumentTest.java index 34572280d01..24dc98e4d93 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/SchemaMustHaveDocumentTest.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/SchemaMustHaveDocumentTest.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.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -17,7 +17,7 @@ public class SchemaMustHaveDocumentTest { @Test public void requireErrorWhenMissingDocument() throws IOException, ParseException { try { - SearchBuilder.buildFromFile("src/test/examples/invalid_sd_missing_document.sd"); + SchemaBuilder.buildFromFile("src/test/examples/invalid_sd_missing_document.sd"); fail("SD without document"); } catch (IllegalArgumentException e) { if (!e.getMessage() 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 e0593aef1e3..abb3558c052 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 @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.documentmodel.SummaryTransform; import org.junit.Test; @@ -39,7 +39,7 @@ public class SummaryConsistencyTestCase { "", "}" ); - Schema schema = SearchBuilder.createFromString(sd).getSearch(); + Schema schema = SchemaBuilder.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 014ca4ec5e9..eb3e61b9f7a 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 @@ -5,7 +5,7 @@ import com.yahoo.config.model.application.provider.BaseDeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.model.container.search.QueryProfiles; @@ -21,7 +21,7 @@ public class SummaryFieldsMustHaveValidSourceTestCase extends AbstractSchemaTest @Test public void requireThatInvalidSourceIsCaught() throws IOException, ParseException { try { - SearchBuilder.buildFromFile("src/test/examples/invalidsummarysource.sd"); + SchemaBuilder.buildFromFile("src/test/examples/invalidsummarysource.sd"); fail("This should throw and never get here"); } catch (IllegalArgumentException e) { assertEquals("For schema 'invalidsummarysource', summary class 'baz', summary field 'cox': there is no valid source 'nonexistingfield'.", e.getMessage()); @@ -31,7 +31,7 @@ public class SummaryFieldsMustHaveValidSourceTestCase extends AbstractSchemaTest @Test public void requireThatInvalidImplicitSourceIsCaught() throws IOException, ParseException { try { - SearchBuilder.buildFromFile("src/test/examples/invalidimplicitsummarysource.sd"); + SchemaBuilder.buildFromFile("src/test/examples/invalidimplicitsummarysource.sd"); fail("This should throw and never get here"); } catch (IllegalArgumentException e) { assertEquals("For schema 'invalidsummarysource', summary class 'baz', summary field 'cox': there is no valid source 'cox'.", e.getMessage()); @@ -41,7 +41,7 @@ public class SummaryFieldsMustHaveValidSourceTestCase extends AbstractSchemaTest @Test public void requireThatInvalidSelfReferingSingleSource() throws IOException, ParseException { try { - SearchBuilder.buildFromFile("src/test/examples/invalidselfreferringsummary.sd"); + SchemaBuilder.buildFromFile("src/test/examples/invalidselfreferringsummary.sd"); fail("This should throw and never get here"); } catch (IllegalArgumentException e) { assertEquals("For schema 'invalidselfreferringsummary', summary class 'withid', summary field 'w': there is no valid source 'w'.", e.getMessage()); @@ -50,7 +50,7 @@ public class SummaryFieldsMustHaveValidSourceTestCase extends AbstractSchemaTest @Test public void requireThatDocumentIdIsAllowedToPass() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/documentidinsummary.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/documentidinsummary.sd"); BaseDeployLogger deployLogger = new BaseDeployLogger(); RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); new SummaryFieldsMustHaveValidSource(schema, deployLogger, rankProfileRegistry, new QueryProfiles()).process(true, false); 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 cef00346fe7..867cb26cbe6 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 @@ -1,13 +1,12 @@ // 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.config.model.test.TestUtil; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; -import static com.yahoo.searchdefinition.SearchBuilder.createFromString; +import static com.yahoo.searchdefinition.SchemaBuilder.createFromString; import static com.yahoo.config.model.test.TestUtil.joinLines; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; 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 888cd22c1c3..b4c2260ea4f 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 @@ -14,7 +14,7 @@ import com.yahoo.searchdefinition.LargeRankExpressions; import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.derived.AttributeFields; import com.yahoo.searchdefinition.derived.RawRankProfile; @@ -140,7 +140,7 @@ public class TensorTransformTestCase extends AbstractSchemaTestCase { private List> buildSearch(String expression) throws ParseException { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); QueryProfileRegistry queryProfiles = setupQueryProfileTypes(); - SearchBuilder builder = new SearchBuilder(rankProfileRegistry, queryProfiles); + SchemaBuilder builder = new SchemaBuilder(rankProfileRegistry, queryProfiles); builder.importString( "search test {\n" + " document test { \n" + 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 e9aec9b7293..2a737f4eb69 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 @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -16,7 +16,7 @@ public class WeightedSetSummaryToTestCase extends AbstractSchemaTestCase { @Test public void testRequireThatImplicitFieldsAreCreated() throws IOException, ParseException { - Schema schema = SearchBuilder.buildFromFile("src/test/examples/weightedset-summaryto.sd"); + Schema schema = SchemaBuilder.buildFromFile("src/test/examples/weightedset-summaryto.sd"); assertNotNull(schema); } diff --git a/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderImportedFieldsTestCase.java b/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderImportedFieldsTestCase.java index 599ae77a456..26ddc8ede8f 100644 --- a/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderImportedFieldsTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderImportedFieldsTestCase.java @@ -1,7 +1,7 @@ // Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.documentmodel; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -27,7 +27,7 @@ public class DocumentModelBuilderImportedFieldsTestCase extends AbstractReferenc } private static class TestDocumentModelBuilder { - private final SearchBuilder builder = new SearchBuilder(); + private final SchemaBuilder builder = new SchemaBuilder(); public TestDocumentModelBuilder addCampaign() throws ParseException { builder.importString(joinLines("search campaign {", " document campaign {", diff --git a/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderReferenceTypeTestCase.java b/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderReferenceTypeTestCase.java index 189b514c294..f9b9bf2610e 100644 --- a/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderReferenceTypeTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderReferenceTypeTestCase.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.documentmodel; import com.yahoo.document.ReferenceDataType; import com.yahoo.documentmodel.NewDocumentType; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.parser.ParseException; import org.junit.Test; @@ -56,7 +56,7 @@ public class DocumentModelBuilderReferenceTypeTestCase extends AbstractReference } private static class TestDocumentModelBuilder { - private final SearchBuilder builder = new SearchBuilder(); + private final SchemaBuilder builder = new SchemaBuilder(); public TestDocumentModelBuilder addCampaign() throws ParseException { builder.importString(joinLines("search campaign {", " document campaign {}", diff --git a/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderTestCase.java b/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderTestCase.java index 15de4b8c02e..79893385199 100644 --- a/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderTestCase.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.documentmodel; import com.yahoo.document.DocumenttypesConfig; import com.yahoo.document.config.DocumentmanagerConfig; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.AbstractSchemaTestCase; import com.yahoo.searchdefinition.parser.ParseException; import com.yahoo.vespa.configmodel.producers.DocumentManager; @@ -35,7 +35,7 @@ public class DocumentModelBuilderTestCase extends AbstractSchemaTestCase { @Test public void testDocumentTypesWithDocumentField() throws IOException, ParseException { - SearchBuilder search = new SearchBuilder(); + SchemaBuilder search = new SchemaBuilder(); search.importFile("src/test/configmodel/types/other_doc.sd"); search.importFile("src/test/configmodel/types/type_with_doc_field.sd"); search.build(); @@ -48,7 +48,7 @@ public class DocumentModelBuilderTestCase extends AbstractSchemaTestCase { @Test public void testMultipleInheritanceArray() throws IOException, ParseException { - SearchBuilder search = new SearchBuilder(); + SchemaBuilder search = new SchemaBuilder(); search.importFile("src/test/cfg/search/data/travel/schemas/TTData.sd"); search.importFile("src/test/cfg/search/data/travel/schemas/TTEdge.sd"); search.importFile("src/test/cfg/search/data/travel/schemas/TTPOI.sd"); @@ -56,7 +56,7 @@ public class DocumentModelBuilderTestCase extends AbstractSchemaTestCase { } private DocumentModel createAndTestModel(String sd) throws IOException, ParseException { - SearchBuilder search = SearchBuilder.createFromFile(sd); + SchemaBuilder search = SchemaBuilder.createFromFile(sd); DocumentModel model = search.getModel(); assertEquals(2, model.getDocumentManager().getTypes().size()); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaClusterTest.java index 27dda6a6bb2..66cbdabf0cb 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaClusterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/search/test/SchemaClusterTest.java @@ -6,7 +6,7 @@ import com.yahoo.container.QrSearchersConfig; import com.yahoo.document.DataType; import com.yahoo.search.config.ClusterConfig; import com.yahoo.searchdefinition.Schema; -import com.yahoo.searchdefinition.SearchBuilder; +import com.yahoo.searchdefinition.SchemaBuilder; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; @@ -56,7 +56,7 @@ public class SchemaClusterTest { sdt2.addField(f2); schema2.addDocument(sdt2); - SearchBuilder builder = new SearchBuilder(); + SchemaBuilder builder = new SchemaBuilder(); builder.importRawSearch(schema1); builder.importRawSearch(schema2); builder.build(); -- cgit v1.2.3