diff options
Diffstat (limited to 'config-model/src/main')
20 files changed, 118 insertions, 127 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/ConfigDefinitionStore.java b/config-model/src/main/java/com/yahoo/config/model/deploy/ConfigDefinitionStore.java index 140cb3001a0..b9ad830090c 100644 --- a/config-model/src/main/java/com/yahoo/config/model/deploy/ConfigDefinitionStore.java +++ b/config-model/src/main/java/com/yahoo/config/model/deploy/ConfigDefinitionStore.java @@ -8,7 +8,6 @@ import java.util.Optional; /** * @author Ulf Lilleengen - * @since 5.1 */ public interface ConfigDefinitionStore { 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 074b19d7238..01809faa2f6 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 @@ -36,9 +36,8 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; import com.yahoo.vespa.model.container.search.QueryProfilesBuilder; import com.yahoo.vespa.model.container.search.SemanticRuleBuilder; import com.yahoo.vespa.model.container.search.SemanticRules; -import com.yahoo.vespa.model.search.SearchDefinition; +import com.yahoo.vespa.model.search.NamedSchema; -import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.Reader; @@ -62,7 +61,7 @@ public class DeployState implements ConfigDefinitionStore { private final DeployLogger logger; private final FileRegistry fileRegistry; private final DocumentModel documentModel; - private final List<SearchDefinition> searchDefinitions; + private final List<NamedSchema> schemas; private final ApplicationPackage applicationPackage; private final Optional<ConfigDefinitionRepo> configDefinitionRepo; private final Optional<ApplicationPackage> permanentApplicationPackage; @@ -122,7 +121,7 @@ public class DeployState implements ConfigDefinitionStore { this.previousModel = previousModel; this.accessLoggingEnabledByDefault = accessLoggingEnabledByDefault; this.provisioner = hostProvisioner.orElse(getDefaultModelHostProvisioner(applicationPackage)); - this.searchDefinitions = searchDocumentModel.getSearchDefinitions(); + this.schemas = searchDocumentModel.getSchemas(); this.documentModel = searchDocumentModel.getDocumentModel(); this.permanentApplicationPackage = permanentApplicationPackage; this.configDefinitionRepo = configDefinitionRepo; @@ -209,8 +208,8 @@ public class DeployState implements ConfigDefinitionStore { return applicationPackage; } - public List<SearchDefinition> getSearchDefinitions() { - return searchDefinitions; + public List<NamedSchema> getSchemas() { + return schemas; } public DocumentModel getDocumentModel() { @@ -427,20 +426,18 @@ public class DeployState implements ConfigDefinitionStore { for (NamedReader reader : readers) { try { String readerName = reader.getName(); - String searchName = builder.importReader(reader, readerName, logger); + String topLevelName = builder.importReader(reader, readerName, logger); String sdName = stripSuffix(readerName, ApplicationPackage.SD_NAME_SUFFIX); - names.put(searchName, sdName); - if ( ! sdName.equals(searchName)) { - throw new IllegalArgumentException("Search definition file name ('" + sdName + "') and name of " + - "search element ('" + searchName + + names.put(topLevelName, sdName); + if ( ! sdName.equals(topLevelName)) { + throw new IllegalArgumentException("Schema definition file name ('" + sdName + "') and name of " + + "top level element ('" + topLevelName + "') are not equal for file '" + readerName + "'"); } } catch (ParseException e) { - throw new IllegalArgumentException("Could not parse search definition file '" + - getSearchDefinitionRelativePath(reader.getName()) + "': " + e.getMessage(), e); + throw new IllegalArgumentException("Could not parse sd file '" + reader.getName(), e); } catch (IOException e) { - throw new IllegalArgumentException("Could not read search definition file '" + - getSearchDefinitionRelativePath(reader.getName()) + "': " + e.getMessage(), e); + throw new IllegalArgumentException("Could not read sd file '" + reader.getName(), e); } finally { closeIgnoreException(reader.getReader()); } @@ -449,10 +446,6 @@ public class DeployState implements ConfigDefinitionStore { return SearchDocumentModel.fromBuilderAndNames(builder, names); } - private String getSearchDefinitionRelativePath(String name) { - return ApplicationPackage.SEARCH_DEFINITIONS_DIR + File.separator + name; - } - private static String stripSuffix(String nodeName, String postfix) { assert (nodeName.endsWith(postfix)); return nodeName.substring(0, nodeName.length() - postfix.length()); 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 cdd4f6f8e8a..9b9729dddb3 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 @@ -3,7 +3,7 @@ package com.yahoo.config.model.deploy; import com.yahoo.searchdefinition.SearchBuilder; import com.yahoo.vespa.documentmodel.DocumentModel; -import com.yahoo.vespa.model.search.SearchDefinition; +import com.yahoo.vespa.model.search.NamedSchema; import java.util.ArrayList; import java.util.List; @@ -13,16 +13,15 @@ import java.util.Map; * Internal helper class to retrieve document model and search definitions. * * @author Ulf Lilleengen - * @since 5.1 */ public class SearchDocumentModel { private final DocumentModel documentModel; - private final List<SearchDefinition> searchDefinitions; + private final List<NamedSchema> schemas; - public SearchDocumentModel(DocumentModel documentModel, List<SearchDefinition> searchDefinitions) { + public SearchDocumentModel(DocumentModel documentModel, List<NamedSchema> schemas) { this.documentModel = documentModel; - this.searchDefinitions = searchDefinitions; + this.schemas = schemas; } @@ -30,22 +29,22 @@ public class SearchDocumentModel { return documentModel; } - public List<SearchDefinition> getSearchDefinitions() { - return searchDefinitions; + public List<NamedSchema> getSchemas() { + return schemas; } public static SearchDocumentModel fromBuilderAndNames(SearchBuilder builder, Map<String, String> names) { - List<SearchDefinition> ret = new ArrayList<>(); + List<NamedSchema> ret = new ArrayList<>(); for (com.yahoo.searchdefinition.Search search : builder.getSearchList()) { - ret.add(new SearchDefinition(names.get(search.getName()), search)); + ret.add(new NamedSchema(names.get(search.getName()), search)); } return new SearchDocumentModel(builder.getModel(), ret); } public static SearchDocumentModel fromBuilder(SearchBuilder builder) { - List<SearchDefinition> ret = new ArrayList<>(); + List<NamedSchema> ret = new ArrayList<>(); for (com.yahoo.searchdefinition.Search search : builder.getSearchList()) { - ret.add(new SearchDefinition(search.getName(), search)); + ret.add(new NamedSchema(search.getName(), search)); } return new SearchDocumentModel(builder.getModel(), ret); } 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 eb61bda83a6..10649df88e1 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 @@ -55,23 +55,23 @@ public class MockApplicationPackage implements ApplicationPackage { private final File root; private final String hostsS; private final String servicesS; - private final List<String> searchDefinitions; - private final String searchDefinitionDir; + private final List<String> schemas; + private final String schemaDir; private final Optional<String> deploymentSpec; private final Optional<String> validationOverrides; private final boolean failOnValidateXml; private final QueryProfileRegistry queryProfileRegistry; private final ApplicationMetaData applicationMetaData; - protected MockApplicationPackage(File root, String hosts, String services, List<String> searchDefinitions, - String searchDefinitionDir, + protected MockApplicationPackage(File root, String hosts, String services, List<String> schemas, + String schemaDir, String deploymentSpec, String validationOverrides, boolean failOnValidateXml, String queryProfile, String queryProfileType) { this.root = root; this.hostsS = hosts; this.servicesS = services; - this.searchDefinitions = searchDefinitions; - this.searchDefinitionDir = searchDefinitionDir; + this.schemas = schemas; + this.schemaDir = schemaDir; this.deploymentSpec = Optional.ofNullable(deploymentSpec); this.validationOverrides = Optional.ofNullable(validationOverrides); this.failOnValidateXml = failOnValidateXml; @@ -108,7 +108,7 @@ public class MockApplicationPackage implements ApplicationPackage { @Override public Reader getHosts() { - if (hostsS==null) return null; + if (hostsS == null) return null; return new StringReader(hostsS); } @@ -118,7 +118,7 @@ public class MockApplicationPackage implements ApplicationPackage { SearchBuilder searchBuilder = new SearchBuilder(this, new RankProfileRegistry(), queryProfileRegistry); - for (String sd : searchDefinitions) { + for (String sd : schemas) { try { String name = searchBuilder.importString(sd); readers.add(new NamedReader(name + ApplicationPackage.SD_NAME_SUFFIX, new StringReader(sd))); @@ -184,7 +184,7 @@ public class MockApplicationPackage implements ApplicationPackage { @Override public Reader getRankingExpression(String name) { - File expressionFile = new File(searchDefinitionDir, name); + File expressionFile = new File(schemaDir, name); try { return IOUtils.createReader(expressionFile, "utf-8"); } @@ -200,9 +200,9 @@ public class MockApplicationPackage implements ApplicationPackage { public static ApplicationPackage fromSearchDefinitionDirectory(String dir) { return new MockApplicationPackage.Builder() - .withEmptyHosts() - .withEmptyServices() - .withSearchDefinitionDir(dir).build(); + .withEmptyHosts() + .withEmptyServices() + .withSchemaDir(dir).build(); } public static class Builder { @@ -210,8 +210,8 @@ public class MockApplicationPackage implements ApplicationPackage { private File root = new File("nonexisting"); private String hosts = null; private String services = null; - private List<String> searchDefinitions = Collections.emptyList(); - private String searchDefinitionDir = null; + private List<String> schemas = Collections.emptyList(); + private String schemaDir = null; private String deploymentSpec = null; private String validationOverrides = null; private boolean failOnValidateXml = false; @@ -245,17 +245,17 @@ public class MockApplicationPackage implements ApplicationPackage { } public Builder withSearchDefinition(String searchDefinition) { - this.searchDefinitions = Collections.singletonList(searchDefinition); + this.schemas = Collections.singletonList(searchDefinition); return this; } - public Builder withSearchDefinitions(List<String> searchDefinition) { - this.searchDefinitions = Collections.unmodifiableList(searchDefinition); + public Builder withSchemas(List<String> searchDefinition) { + this.schemas = Collections.unmodifiableList(searchDefinition); return this; } - public Builder withSearchDefinitionDir(String searchDefinitionDir) { - this.searchDefinitionDir = searchDefinitionDir; + public Builder withSchemaDir(String schemaDir) { + this.schemaDir = schemaDir; return this; } @@ -285,7 +285,7 @@ public class MockApplicationPackage implements ApplicationPackage { } public ApplicationPackage build() { - return new MockApplicationPackage(root, hosts, services, searchDefinitions, searchDefinitionDir, + return new MockApplicationPackage(root, hosts, services, schemas, schemaDir, deploymentSpec, validationOverrides, failOnValidateXml, queryProfile, queryProfileType); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentReferenceResolver.java b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentReferenceResolver.java index 14f8a0a9d37..0d0da71bd0f 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentReferenceResolver.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentReferenceResolver.java @@ -25,8 +25,8 @@ public class DocumentReferenceResolver { private final Map<String, Search> searchMapping; - public DocumentReferenceResolver(List<Search> searchDefinitions) { - this.searchMapping = createDocumentNameToSearchMapping(searchDefinitions); + public DocumentReferenceResolver(List<Search> schemas) { + this.searchMapping = createDocumentNameToSearchMapping(schemas); } public void resolveReferences(SDDocumentType documentType) { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/ImportedFieldsEnumerator.java b/config-model/src/main/java/com/yahoo/searchdefinition/ImportedFieldsEnumerator.java index ee4fc41f2f9..25cdd1e08cd 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/ImportedFieldsEnumerator.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/ImportedFieldsEnumerator.java @@ -2,9 +2,7 @@ package com.yahoo.searchdefinition; import com.yahoo.searchdefinition.document.SDDocumentType; -import com.yahoo.searchdefinition.document.TemporaryImportedFields; -import java.util.Collections; import java.util.List; /** @@ -13,17 +11,17 @@ import java.util.List; */ public class ImportedFieldsEnumerator { - private final List<Search> searchDefinitions; + private final List<Search> schemas; - public ImportedFieldsEnumerator(List<Search> searchDefinitions) { - this.searchDefinitions = searchDefinitions; + public ImportedFieldsEnumerator(List<Search> schemas) { + this.schemas = schemas; } public void enumerateImportedFields(SDDocumentType documentType) { - var search = this.searchDefinitions.stream() - .filter(s -> s.getDocument() != null) - .filter(s -> s.getDocument().getName().equals(documentType.getName())) - .findFirst(); + var search = this.schemas.stream() + .filter(s -> s.getDocument() != null) + .filter(s -> s.getDocument().getName().equals(documentType.getName())) + .findFirst(); if (search.isEmpty()) { return; // No imported fields present. } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/Search.java b/config-model/src/main/java/com/yahoo/searchdefinition/Search.java index f90a7e4f6cd..0ab8a2308a4 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/Search.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/Search.java @@ -288,7 +288,7 @@ public class Search implements ImmutableSearch { /** * Adds an extra field of this search definition not contained in a document * - * @param field to add to the searchdefinitions list of external fields. + * @param field to add to the schemas list of external fields */ public void addExtraField(SDField field) { if (fields.containsKey(field.getName())) { @@ -383,7 +383,7 @@ public class Search implements ImmutableSearch { * Consolidates a set of index settings for the same index into one * * @param indices The list of indexes to consolidate. - * @return The consolidated index + * @return the consolidated index */ private Index consolidateIndices(List<Index> indices) { Index first = indices.get(0); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java index f9762ce58fa..43c1a88b0a1 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java @@ -33,7 +33,7 @@ public class ComplexAttributeFieldsValidator extends Validator { continue; } SearchCluster searchCluster = (SearchCluster) cluster; - for (AbstractSearchCluster.SearchDefinitionSpec spec : searchCluster.getLocalSDS()) { + for (AbstractSearchCluster.SchemaSpec spec : searchCluster.getLocalSDS()) { validateComplexFields(searchCluster.getClusterName(), spec.getSearchDefinition().getSearch()); } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankingConstantsValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankingConstantsValidator.java index 907418ea9f0..9568ea5c27c 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankingConstantsValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankingConstantsValidator.java @@ -9,7 +9,7 @@ import com.yahoo.path.Path; import com.yahoo.searchdefinition.RankingConstant; import com.yahoo.vespa.model.VespaModel; import com.yahoo.vespa.model.application.validation.ConstantTensorJsonValidator.InvalidConstantTensor; -import com.yahoo.vespa.model.search.SearchDefinition; +import com.yahoo.vespa.model.search.NamedSchema; import java.io.FileNotFoundException; @@ -47,7 +47,7 @@ public class RankingConstantsValidator extends Validator { ApplicationPackage applicationPackage = deployState.getApplicationPackage(); ExceptionMessageCollector exceptionMessageCollector = new ExceptionMessageCollector("Invalid constant tensor file(s):"); - for (SearchDefinition sd : deployState.getSearchDefinitions()) { + for (NamedSchema sd : deployState.getSchemas()) { for (RankingConstant rc : sd.getSearch().rankingConstants().asMap().values()) { try { validateRankingConstant(rc, applicationPackage); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/SearchDataTypeValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/SearchDataTypeValidator.java index 85ba75639eb..031ce0dbdd4 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/SearchDataTypeValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/SearchDataTypeValidator.java @@ -15,7 +15,7 @@ import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.vespa.model.VespaModel; import com.yahoo.vespa.model.search.AbstractSearchCluster; -import com.yahoo.vespa.model.search.SearchDefinition; +import com.yahoo.vespa.model.search.NamedSchema; import java.util.List; @@ -34,7 +34,7 @@ public class SearchDataTypeValidator extends Validator { if (cluster.isStreaming()) { continue; } - for (AbstractSearchCluster.SearchDefinitionSpec spec : cluster.getLocalSDS()) { + for (AbstractSearchCluster.SchemaSpec spec : cluster.getLocalSDS()) { SDDocumentType docType = spec.getSearchDefinition().getSearch().getDocument(); if (docType == null) { continue; @@ -44,7 +44,7 @@ public class SearchDataTypeValidator extends Validator { } } - private void validateDocument(AbstractSearchCluster cluster, SearchDefinition def, SDDocumentType doc) { + private void validateDocument(AbstractSearchCluster cluster, NamedSchema def, SDDocumentType doc) { for (SDDocumentType child : doc.getTypes()) { validateDocument(cluster, def, child); } @@ -84,7 +84,7 @@ public class SearchDataTypeValidator extends Validator { } } - private void disallowIndexingOfMaps(AbstractSearchCluster cluster, SearchDefinition def, Field field) { + private void disallowIndexingOfMaps(AbstractSearchCluster cluster, NamedSchema def, Field field) { DataType fieldType = field.getDataType(); if ((fieldType instanceof MapDataType) && (((SDField) field).doesIndexing())) { throw new IllegalArgumentException("Field type '" + fieldType.getName() + "' cannot be indexed for search " + diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java index fa5fa4bd227..4c4b1ca7f82 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java @@ -8,7 +8,6 @@ import com.yahoo.search.pagetemplates.PageTemplatesConfig; import com.yahoo.search.query.profile.config.QueryProfilesConfig; import com.yahoo.vespa.configdefinition.IlscriptsConfig; import com.yahoo.vespa.model.container.ApplicationContainerCluster; -import com.yahoo.vespa.model.container.component.Component; import com.yahoo.vespa.model.container.component.ContainerSubsystem; import com.yahoo.vespa.model.container.search.searchchain.LocalProvider; import com.yahoo.vespa.model.container.search.searchchain.SearchChains; @@ -132,7 +131,7 @@ public class ContainerSearch extends ContainerSubsystem<SearchChains> AbstractSearchCluster sys = findClusterWithId(searchClusters, i); QrSearchersConfig.Searchcluster.Builder scB = new QrSearchersConfig.Searchcluster.Builder(). name(sys.getClusterName()); - for (AbstractSearchCluster.SearchDefinitionSpec spec : sys.getLocalSDS()) { + for (AbstractSearchCluster.SchemaSpec spec : sys.getLocalSDS()) { scB.searchdef(spec.getSearchDefinition().getName()); } scB.rankprofiles(new QrSearchersConfig.Searchcluster.Rankprofiles.Builder().configid(sys.getConfigId())); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/LocalProvider.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/LocalProvider.java index e05b2d27e09..4ecc666a9f2 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/LocalProvider.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/LocalProvider.java @@ -118,7 +118,7 @@ public class LocalProvider extends Provider implements public List<String> getDocumentTypes() { List<String> documentTypes = new ArrayList<>(); - for (AbstractSearchCluster.SearchDefinitionSpec spec : searchCluster.getLocalSDS()) { + for (AbstractSearchCluster.SchemaSpec spec : searchCluster.getLocalSDS()) { documentTypes.add(spec.getSearchDefinition().getSearch().getDocument().getName()); } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java index fa822df652f..fcaba66ef69 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java @@ -16,8 +16,8 @@ import com.yahoo.vespa.model.search.AbstractSearchCluster; import com.yahoo.vespa.model.search.IndexedSearchCluster; import com.yahoo.vespa.model.search.NodeSpec; import com.yahoo.vespa.model.search.SearchCluster; -import com.yahoo.vespa.model.search.SearchDefinition; -import com.yahoo.vespa.model.search.SearchDefinitionXMLHandler; +import com.yahoo.vespa.model.search.NamedSchema; +import com.yahoo.vespa.model.search.SchemaDefinitionXMLHandler; import com.yahoo.vespa.model.search.SearchNode; import com.yahoo.vespa.model.search.StreamingSearchCluster; import com.yahoo.vespa.model.search.TransactionLogServer; @@ -136,7 +136,7 @@ public class ContentSearchCluster extends AbstractConfigProducer implements Prot private void buildIndexedSearchCluster(DeployState deployState, ModelElement clusterElem, String clusterName, ContentSearchCluster search) { - List<ModelElement> indexedDefs = getIndexedSearchDefinitions(clusterElem); + List<ModelElement> indexedDefs = getIndexedSchemas(clusterElem); if (!indexedDefs.isEmpty()) { IndexedSearchCluster isc = new IndexedSearchCluster(search, clusterName, 0, deployState); isc.setRoutingSelector(clusterElem.childAsString("documents.selection")); @@ -150,7 +150,7 @@ public class ContentSearchCluster extends AbstractConfigProducer implements Prot } } - private List<ModelElement> getIndexedSearchDefinitions(ModelElement clusterElem) { + private List<ModelElement> getIndexedSchemas(ModelElement clusterElem) { List<ModelElement> indexedDefs = new ArrayList<>(); ModelElement docElem = clusterElem.child("documents"); if (docElem == null) { @@ -188,28 +188,28 @@ public class ContentSearchCluster extends AbstractConfigProducer implements Prot } private void addSearchCluster(DeployState deployState, SearchCluster cluster, Double queryTimeout, List<ModelElement> documentDefs) { - addSearchDefinitions(deployState, documentDefs, cluster); + addSchemas(deployState, documentDefs, cluster); if (queryTimeout != null) { cluster.setQueryTimeout(queryTimeout); } cluster.defaultDocumentsConfig(); - cluster.deriveSearchDefinitions(deployState); + cluster.deriveSchemas(deployState); addCluster(cluster); } - private void addSearchDefinitions(DeployState deployState, List<ModelElement> searchDefs, AbstractSearchCluster sc) { + private void addSchemas(DeployState deployState, List<ModelElement> searchDefs, AbstractSearchCluster sc) { for (ModelElement e : searchDefs) { - SearchDefinitionXMLHandler searchDefinitionXMLHandler = new SearchDefinitionXMLHandler(e); - SearchDefinition searchDefinition = - searchDefinitionXMLHandler.getResponsibleSearchDefinition(deployState.getSearchDefinitions()); + SchemaDefinitionXMLHandler schemaDefinitionXMLHandler = new SchemaDefinitionXMLHandler(e); + NamedSchema searchDefinition = + schemaDefinitionXMLHandler.getResponsibleSearchDefinition(deployState.getSchemas()); if (searchDefinition == null) throw new RuntimeException("Search definition parsing error or file does not exist: '" + - searchDefinitionXMLHandler.getName() + "'"); + schemaDefinitionXMLHandler.getName() + "'"); // TODO: remove explicit building of user configs when the complete content model is built using builders. - sc.getLocalSDS().add(new AbstractSearchCluster.SearchDefinitionSpec(searchDefinition, - UserConfigBuilder.build(e.getXml(), deployState, deployState.getDeployLogger()))); + sc.getLocalSDS().add(new AbstractSearchCluster.SchemaSpec(searchDefinition, + UserConfigBuilder.build(e.getXml(), deployState, deployState.getDeployLogger()))); //need to get the document names from this sdfile sc.addDocumentNames(searchDefinition); } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/AbstractSearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/search/AbstractSearchCluster.java index 8a88e720bed..fe6c6c52e2d 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/AbstractSearchCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/search/AbstractSearchCluster.java @@ -29,7 +29,7 @@ public abstract class AbstractSearchCluster extends AbstractConfigProducer protected int index; private Double visibilityDelay = 0.0; private List<String> documentNames = new ArrayList<>(); - private List<SearchDefinitionSpec> localSDS = new LinkedList<>(); + private List<SchemaSpec> localSDS = new LinkedList<>(); public AbstractSearchCluster(AbstractConfigProducer parent, String clusterName, int index) { super(parent, "cluster." + clusterName); @@ -38,11 +38,11 @@ public abstract class AbstractSearchCluster extends AbstractConfigProducer } public void prepareToDistributeFiles(List<SearchNode> backends) { - for (SearchDefinitionSpec sds : localSDS) + for (SchemaSpec sds : localSDS) sds.getSearchDefinition().getSearch().rankingConstants().sendTo(backends); } - public void addDocumentNames(SearchDefinition searchDefinition) { + public void addDocumentNames(NamedSchema searchDefinition) { String dName = searchDefinition.getSearch().getDocument().getDocumentName().getName(); documentNames.add(dName); } @@ -50,7 +50,7 @@ public abstract class AbstractSearchCluster extends AbstractConfigProducer /** Returns a List with document names used in this search cluster */ public List<String> getDocumentNames() { return documentNames; } - public List<SearchDefinitionSpec> getLocalSDS() { + public List<SchemaSpec> getLocalSDS() { return localSDS; } @@ -107,18 +107,17 @@ public abstract class AbstractSearchCluster extends AbstractConfigProducer } } - public static final class SearchDefinitionSpec { + public static final class SchemaSpec { - private final SearchDefinition searchDefinition; + private final NamedSchema searchDefinition; private final UserConfigRepo userConfigRepo; - public SearchDefinitionSpec(SearchDefinition searchDefinition, - UserConfigRepo userConfigRepo) { + public SchemaSpec(NamedSchema searchDefinition, UserConfigRepo userConfigRepo) { this.searchDefinition = searchDefinition; this.userConfigRepo = userConfigRepo; } - public SearchDefinition getSearchDefinition() { + public NamedSchema getSearchDefinition() { return searchDefinition; } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/IndexedSearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/search/IndexedSearchCluster.java index 3c45b29b1e2..9746c50450e 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/IndexedSearchCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/search/IndexedSearchCluster.java @@ -195,9 +195,10 @@ public class IndexedSearchCluster extends SearchCluster routingSelector = sb.toString(); } } + @Override - protected void deriveAllSearchDefinitions(List<SearchDefinitionSpec> localSearches, DeployState deployState) { - for (SearchDefinitionSpec spec : localSearches) { + protected void deriveAllSchemas(List<SchemaSpec> localSearches, DeployState deployState) { + for (SchemaSpec spec : localSearches) { com.yahoo.searchdefinition.Search search = spec.getSearchDefinition().getSearch(); if ( ! (search instanceof DocumentOnlySearch)) { DocumentDatabase db = new DocumentDatabase(this, search.getName(), diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchDefinition.java b/config-model/src/main/java/com/yahoo/vespa/model/search/NamedSchema.java index 860f89792e2..ba81073709e 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchDefinition.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/search/NamedSchema.java @@ -8,7 +8,8 @@ import java.util.Collection; /** * @author Tony Vaagenes */ -public class SearchDefinition { +// TODO: This class is quite pointless +public class NamedSchema { private final Search search; private final String name; @@ -23,15 +24,15 @@ public class SearchDefinition { return name; } - public SearchDefinition(String name, Search search) { + public NamedSchema(String name, Search search) { this.name = name; this.search = search; } //Find search definition from a collection with the name specified - public static SearchDefinition findByName(final String searchDefinitionName, Collection<SearchDefinition> searchDefinitions) { - for (SearchDefinition candidate : searchDefinitions) { - if (candidate.getName().equals(searchDefinitionName) ) + public static NamedSchema findByName(String schemaName, Collection<NamedSchema> schemas) { + for (NamedSchema candidate : schemas) { + if (candidate.getName().equals(schemaName) ) return candidate; } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchDefinitionXMLHandler.java b/config-model/src/main/java/com/yahoo/vespa/model/search/SchemaDefinitionXMLHandler.java index 1054253e3f0..b505b5e681c 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchDefinitionXMLHandler.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/search/SchemaDefinitionXMLHandler.java @@ -7,15 +7,15 @@ import java.io.Serializable; import java.util.List; /** - * Represents a single searchdefinition file. + * Represents a single schema file. * * @author arnej27959 */ -public class SearchDefinitionXMLHandler implements Serializable { +public class SchemaDefinitionXMLHandler implements Serializable { private String sdName; - public SearchDefinitionXMLHandler(ModelElement elem) { + public SchemaDefinitionXMLHandler(ModelElement elem) { sdName = elem.stringAttribute("name"); if (sdName == null) { sdName = elem.stringAttribute("type"); @@ -24,8 +24,8 @@ public class SearchDefinitionXMLHandler implements Serializable { public String getName() { return sdName; } - public SearchDefinition getResponsibleSearchDefinition(List<SearchDefinition> searchDefinitions) { - return SearchDefinition.findByName( getName(), searchDefinitions ); + public NamedSchema getResponsibleSearchDefinition(List<NamedSchema> schemas) { + return NamedSchema.findByName(getName(), schemas ); } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java index 321564bfec1..0139e949c7a 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java @@ -41,8 +41,8 @@ public abstract class SearchCluster extends AbstractSearchCluster * Also stores the document names contained in the search * definitions. */ - public void deriveSearchDefinitions(DeployState deployState) { - deriveAllSearchDefinitions(getLocalSDS(), deployState); + public void deriveSchemas(DeployState deployState) { + deriveAllSchemas(getLocalSDS(), deployState); } @Override @@ -132,7 +132,7 @@ public abstract class SearchCluster extends AbstractSearchCluster return false; } - protected abstract void deriveAllSearchDefinitions(List<SearchDefinitionSpec> localSearches, DeployState deployState); + protected abstract void deriveAllSchemas(List<SchemaSpec> localSearches, DeployState deployState); public abstract void defaultDocumentsConfig(); public abstract DerivedConfiguration getSdConfig(); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/StreamingSearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/search/StreamingSearchCluster.java index d668adea116..28e7b3eb37a 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/StreamingSearchCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/search/StreamingSearchCluster.java @@ -91,7 +91,7 @@ public class StreamingSearchCluster extends SearchCluster implements } @Override - protected void deriveAllSearchDefinitions(List<SearchDefinitionSpec> local, DeployState deployState) { + protected void deriveAllSchemas(List<SchemaSpec> local, DeployState deployState) { if (local.size() == 1) { deriveSingleSearchDefinition(local.get(0).getSearchDefinition().getSearch(), deployState); } else if (local.size() > 1){ diff --git a/config-model/src/main/javacc/SDParser.jj b/config-model/src/main/javacc/SDParser.jj index 0cfd13f2a9c..2ee0d870d0e 100644 --- a/config-model/src/main/javacc/SDParser.jj +++ b/config-model/src/main/javacc/SDParser.jj @@ -197,6 +197,7 @@ TOKEN : < NL: "\n" > | < ANNOTATION: "annotation" > | < ANNOTATIONREFERENCE: "annotationreference" > +| < SCHEMA: "schema" > | < SEARCH: "search" > | < DIVERSITY: "diversity" > | < MIN_GROUPS: "min-groups" > @@ -403,38 +404,38 @@ Search search(DocumentTypeManager docMan, String dir) : Search search; } { - (<NL>)* (search = rootSearch(dir) | search = rootDocument(dir)) + (<NL>)* (search = rootSchema(dir) | search = rootDocument(dir)) { return search; } } /** - * This rule consumes a proper search block. This and rootDocument() are the only rules that should ever consume + * This rule consumes a proper schema block. This and rootDocument() are the only rules that should ever consume * trailing newline tokens. * - * @param dir The directory containing the file being parsed. - * @return The search definition object. + * @param dir the directory containing the file being parsed. + * @return the schema definition object. */ -Search rootSearch(String dir) : +Search rootSchema(String dir) : { String name; Search search; } { - ( <SEARCH> name = identifier() { search = new Search(name, app); + ( ( <SCHEMA> | <SEARCH> ) name = identifier() { search = new Search(name, app); rankProfileRegistry.add(new DefaultRankProfile(search, rankProfileRegistry)); rankProfileRegistry.add(new UnrankedRankProfile(search, rankProfileRegistry));} - lbrace() (rootSearchItem(search) (<NL>)*)* <RBRACE> (<NL>)* <EOF>) + lbrace() (rootSchemaItem(search) (<NL>)*)* <RBRACE> (<NL>)* <EOF>) { return search; } } /** - * Consumes an element of a search block. This and rootSearch() are the only rules that should ever consume + * Consumes an element of a schema block. This and rootSearch() are the only rules that should ever consume * trailing newline tokens. * * @param search The search object to modify. * @return Null. */ -Object rootSearchItem(Search search) : { } +Object rootSchemaItem(Search search) : { } { ( document(search) | documentSummary(search) @@ -452,10 +453,10 @@ Object rootSearchItem(Search search) : { } } /** - * Consumes a search definition that contains only documents to be used for inheritance, etc. + * Consumes a schema definition that contains only documents to be used for inheritance, etc. * - * @param dir The directory containing the file being parsed. - * @return The search definition object. + * @param dir the directory containing the file being parsed. + * @return the schema definition object. */ Search rootDocument(String dir) : { @@ -481,7 +482,7 @@ Object rootDocumentItem(Search search) : { } /** * Consumes a use-document statement. This currently does nothing. * - * @param search The search object to modify. + * @param search the search object to modify. */ void useDocument(Search search) : { } { @@ -491,7 +492,7 @@ void useDocument(Search search) : { } /** * Consumes a document element. The name defaults to the search's name, but may be set. * - * @param search The search object to add content to. + * @param search the search object to add content to. */ void document(Search search) : { @@ -510,7 +511,7 @@ void document(Search search) : /** * Consumes a document element, explicitly named * - * @param search The search object to add content to. + * @param search the search object to add content to. */ void namedDocument(Search search) : { @@ -2617,6 +2618,7 @@ String identifier() : { } | <REFERENCE> | <REMOVEIFZERO> | <RERANKCOUNT> + | <SCHEMA> | <SEARCH> | <SECONDARY> | <SECONDPHASE> |