diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-10-20 15:03:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-20 15:03:10 +0200 |
commit | d50cf686dca18ff26ed5a63fb105ccc7f81408c0 (patch) | |
tree | 4d51415040ff2ab43a0b08d6603a80d3926ccfbd /config-model/src/main/java/com/yahoo | |
parent | df3bea6dcbe4ca66316cc364264e550fba47f952 (diff) | |
parent | b6715014182ac6958e23e6c990e3630e77c2791e (diff) |
Merge pull request #19653 from vespa-engine/bratseth/schema-inheritance
Bratseth/schema inheritance
Diffstat (limited to 'config-model/src/main/java/com/yahoo')
127 files changed, 1459 insertions, 1227 deletions
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 d4b7004a1b6..604e2b0a44b 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 @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config.model.deploy; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.SearchBuilder; import com.yahoo.vespa.documentmodel.DocumentModel; import com.yahoo.vespa.model.search.NamedSchema; @@ -35,16 +36,16 @@ public class SearchDocumentModel { public static SearchDocumentModel fromBuilderAndNames(SearchBuilder builder, Map<String, String> names) { List<NamedSchema> ret = new ArrayList<>(); - for (com.yahoo.searchdefinition.Search search : builder.getSearchList()) { - ret.add(new NamedSchema(names.get(search.getName()), search)); + for (Schema schema : builder.getSearchList()) { + ret.add(new NamedSchema(names.get(schema.getName()), schema)); } return new SearchDocumentModel(builder.getModel(), ret); } public static SearchDocumentModel fromBuilder(SearchBuilder builder) { List<NamedSchema> ret = new ArrayList<>(); - for (com.yahoo.searchdefinition.Search search : builder.getSearchList()) { - ret.add(new NamedSchema(search.getName(), search)); + for (Schema schema : builder.getSearchList()) { + ret.add(new NamedSchema(schema.getName(), schema)); } 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 b3da8ca14b9..1ef5dcef411 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 @@ -96,7 +96,7 @@ public class MockApplicationPackage implements ApplicationPackage { protected File root() { return root; } @Override - @SuppressWarnings("deprecation") + @SuppressWarnings("deprecation") // NOT redundant public String getApplicationName() { return "mock application"; } @@ -206,6 +206,15 @@ public class MockApplicationPackage implements ApplicationPackage { .withSchemaDir(dir).build(); } + // TODO: It might work to just merge this and the above + public static ApplicationPackage fromSearchDefinitionAndRootDirectory(String dir) { + return new MockApplicationPackage.Builder() + .withRoot(new File(dir)) + .withEmptyHosts() + .withEmptyServices() + .withSchemaDir(dir).build(); + } + public static class Builder { private File root = new File("nonexisting"); diff --git a/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentType.java b/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentType.java index b9e46989fa3..08a0f8b9882 100644 --- a/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentType.java +++ b/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentType.java @@ -10,7 +10,7 @@ import com.yahoo.document.annotation.AnnotationType; import com.yahoo.document.annotation.AnnotationTypeRegistry; import com.yahoo.document.datatypes.FieldValue; import com.yahoo.searchdefinition.FieldSets; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.FieldSet; import com.yahoo.searchdefinition.processing.BuiltInFieldSets; @@ -22,6 +22,7 @@ import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.Map; +import java.util.Optional; import java.util.Set; import static java.util.Collections.emptySet; @@ -53,7 +54,7 @@ public final class NewDocumentType extends StructuredDataType implements DataTyp this( name, new StructDataType(name.getName() + ".header"), - new FieldSets(), + new FieldSets(Optional.empty()), documentReferences, importedFieldNames); } @@ -337,7 +338,7 @@ public final class NewDocumentType extends StructuredDataType implements DataTyp return this; } - /** The field sets defined for this type and its {@link Search} */ + /** The field sets defined for this type and its {@link Schema} */ public Set<FieldSet> getFieldSets() { return Collections.unmodifiableSet(fieldSets); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/Application.java b/config-model/src/main/java/com/yahoo/searchdefinition/Application.java new file mode 100644 index 00000000000..19a536a18f7 --- /dev/null +++ b/config-model/src/main/java/com/yahoo/searchdefinition/Application.java @@ -0,0 +1,63 @@ +// 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 java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * A collection of objects representing the content of an application package. + * This is created, then added to, and lastly validated when there is no more content to add. + * At that point it is ready to use for deriving configuration. + * + * @author bratseth + */ +public class Application { + + private final ApplicationPackage applicationPackage; + private final RankProfileRegistry rankProfileRegistry; + private final Map<String, Schema> schemas = new LinkedHashMap<>(); + + public Application(ApplicationPackage applicationPackage) { + this(applicationPackage, new RankProfileRegistry()); + } + + // TODO: Almost sure the rank profile registry passed is always new RankProfileRegistry() (apart from in some tests), so remove the parameter + public Application(ApplicationPackage applicationPackage, RankProfileRegistry rankProfileRegistry) { + this.applicationPackage = applicationPackage; + this.rankProfileRegistry = rankProfileRegistry; + } + + public ApplicationPackage applicationPackage() { return applicationPackage; } + + public RankProfileRegistry rankProfileRegistry() { return rankProfileRegistry; } + + public void add(Schema schema) { + if (schemas.containsKey(schema.getName())) + throw new IllegalArgumentException("Duplicate schema '" + schema.getName() + "' in " + this); + schemas.put(schema.getName(), schema); + } + + /** Returns an unmodifiable list of the schemas of this application */ + public Map<String, Schema> schemas() { return Collections.unmodifiableMap(schemas); } + + /** Used by SearchBuilder, for now */ + void replaceSchemasBy(List<Schema> schemas) { + this.schemas.clear(); + for (var schema : schemas) + this.schemas.put(schema.getName(), schema); + } + + /** Validates this. Must be called after all content is added to it. */ + public void validate(DeployLogger logger) { + schemas.values().forEach(schema -> schema.validate(logger)); + } + + @Override + public String toString() { return "application " + applicationPackage.getApplicationId(); } + +} diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/DefaultRankProfile.java b/config-model/src/main/java/com/yahoo/searchdefinition/DefaultRankProfile.java index da611513570..56a739ced8b 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/DefaultRankProfile.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/DefaultRankProfile.java @@ -19,8 +19,8 @@ public class DefaultRankProfile extends RankProfile { * * @param rankProfileRegistry The {@link com.yahoo.searchdefinition.RankProfileRegistry} to use for storing and looking up rank profiles. */ - public DefaultRankProfile(Search search, RankProfileRegistry rankProfileRegistry, RankingConstants rankingConstants) { - super("default", search, rankProfileRegistry, rankingConstants); + public DefaultRankProfile(Schema schema, RankProfileRegistry rankProfileRegistry, RankingConstants rankingConstants) { + super("default", schema, rankProfileRegistry, rankingConstants); } /** diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentModelBuilder.java b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentModelBuilder.java index e7d0b72d46b..14404528acc 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentModelBuilder.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentModelBuilder.java @@ -57,17 +57,17 @@ public class DocumentModelBuilder { return scratchInheritsMap.isEmpty(); } - public void addToModel(Collection<Search> searchList) { + public void addToModel(Collection<Schema> schemaList) { List<SDDocumentType> docList = new LinkedList<>(); - for (Search search : searchList) { - docList.add(search.getDocument()); + for (Schema schema : schemaList) { + docList.add(schema.getDocument()); } docList = sortDocumentTypes(docList); addDocumentTypes(docList); - for (Collection<Search> toAdd = tryAdd(searchList); - ! toAdd.isEmpty() && (toAdd.size() < searchList.size()); - toAdd = tryAdd(searchList)) { - searchList = toAdd; + for (Collection<Schema> toAdd = tryAdd(schemaList); + ! toAdd.isEmpty() && (toAdd.size() < schemaList.size()); + toAdd = tryAdd(schemaList)) { + schemaList = toAdd; } } @@ -116,26 +116,26 @@ public class DocumentModelBuilder { return out.toString(); } - private Collection<Search> tryAdd(Collection<Search> searchList) { - Collection<Search> left = new ArrayList<>(); - for (Search search : searchList) { + private Collection<Schema> tryAdd(Collection<Schema> schemaList) { + Collection<Schema> left = new ArrayList<>(); + for (Schema schema : schemaList) { try { - addToModel(search); + addToModel(schema); } catch (RetryLaterException e) { - left.add(search); + left.add(schema); } } return left; } - public void addToModel(Search search) { + public void addToModel(Schema schema) { // Then we add the search specific stuff - SearchDef searchDef = new SearchDef(search.getName()); - addSearchFields(search.extraFieldList(), searchDef); - for (Field f : search.getDocument().fieldSet()) { + SearchDef searchDef = new SearchDef(schema.getName()); + addSearchFields(schema.extraFieldList(), searchDef); + for (Field f : schema.getDocument().fieldSet()) { addSearchField((SDField) f, searchDef); } - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { for (Attribute attribute : field.getAttributes().values()) { if ( ! searchDef.getFields().containsKey(attribute.getName())) { searchDef.add(new SearchField(new Field(attribute.getName(), field), !field.getIndices().isEmpty(), true)); @@ -143,7 +143,7 @@ public class DocumentModelBuilder { } } - for (Field f : search.getDocument().fieldSet()) { + for (Field f : schema.getDocument().fieldSet()) { addAlias((SDField) f, searchDef); } model.getSearchManager().add(searchDef); @@ -354,10 +354,10 @@ public class DocumentModelBuilder { throw new IllegalArgumentException("Data type '" + sdoc.getName() + "' is not a struct => tostring='" + sdoc.toString() + "'."); } } - for (AnnotationType annotation : sdoc.getAnnotations()) { + for (AnnotationType annotation : sdoc.getAnnotations().values()) { dt.add(annotation); } - for (AnnotationType annotation : sdoc.getAnnotations()) { + for (AnnotationType annotation : sdoc.getAnnotations().values()) { SDAnnotationType sa = (SDAnnotationType) annotation; if (annotation.getInheritedTypes().isEmpty() && (sa.getInherits() != null) ) { annotationInheritance.put(annotation, sa.getInherits()); diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentOnlySearch.java b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentOnlySchema.java index d10aa26f429..c672b662874 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentOnlySearch.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentOnlySchema.java @@ -1,7 +1,6 @@ // 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; @@ -13,10 +12,10 @@ import com.yahoo.searchdefinition.document.SDDocumentType; * * @author vegardh */ -public class DocumentOnlySearch extends Search { +public class DocumentOnlySchema extends Schema { - public DocumentOnlySearch(ApplicationPackage applicationPackage, FileRegistry fileRegistry, DeployLogger deployLogger, ModelContext.Properties properties) { - super(applicationPackage, fileRegistry, deployLogger, properties); + public DocumentOnlySchema(Application application, FileRegistry fileRegistry, DeployLogger deployLogger, ModelContext.Properties properties) { + super(application, fileRegistry, deployLogger, properties); } @Override diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentReference.java b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentReference.java index 2b0ade3797a..145effcdc9d 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentReference.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentReference.java @@ -11,18 +11,18 @@ import com.yahoo.document.Field; public class DocumentReference { private final Field referenceField; - private final Search targetSearch; + private final Schema targetSchema; - public DocumentReference(Field referenceField, Search targetSearch) { + public DocumentReference(Field referenceField, Schema targetSchema) { this.referenceField = referenceField; - this.targetSearch = targetSearch; + this.targetSchema = targetSchema; } public Field referenceField() { return referenceField; } - public Search targetSearch() { - return targetSearch; + public Schema targetSearch() { + return targetSchema; } } 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 95fdd5dc297..26c140e58fe 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentReferenceResolver.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentReferenceResolver.java @@ -7,7 +7,6 @@ import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; import java.util.Collection; -import java.util.List; import java.util.Map; import java.util.stream.Stream; @@ -24,9 +23,9 @@ import static java.util.stream.Collectors.toMap; */ public class DocumentReferenceResolver { - private final Map<String, Search> searchMapping; + private final Map<String, Schema> searchMapping; - public DocumentReferenceResolver(List<Search> schemas) { + public DocumentReferenceResolver(Collection<Schema> schemas) { this.searchMapping = createDocumentNameToSearchMapping(schemas); } @@ -64,13 +63,13 @@ public class DocumentReferenceResolver { } ReferenceDataType reference = (ReferenceDataType) field.getDataType(); String targetDocumentName = getTargetDocumentName(reference); - Search search = searchMapping.get(targetDocumentName); - if (search == null) { + Schema schema = searchMapping.get(targetDocumentName); + if (schema == null) { throw new IllegalArgumentException( String.format("Invalid document reference '%s': " + "Could not find document type '%s'", field.getName(), targetDocumentName)); } - return new DocumentReference(field, search); + return new DocumentReference(field, schema); } private static boolean isAttribute(Field field) { @@ -78,10 +77,10 @@ public class DocumentReferenceResolver { return sdField.doesAttributing(); } - private static Map<String, Search> createDocumentNameToSearchMapping(List<Search> searchDefintions) { - return searchDefintions.stream() - .filter(search -> search.getDocument() != null) - .collect(toMap(search -> search.getDocument().getName(), identity())); + private static Map<String, Schema> createDocumentNameToSearchMapping(Collection<Schema> schemaDefintions) { + return schemaDefintions.stream() + .filter(search -> search.getDocument() != null) + .collect(toMap(search -> search.getDocument().getName(), identity())); } private static Stream<Field> fieldStream(SDDocumentType documentType) { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentsOnlyRankProfile.java b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentsOnlyRankProfile.java index a6694ed7bff..acab2b96772 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentsOnlyRankProfile.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentsOnlyRankProfile.java @@ -14,9 +14,9 @@ import java.util.List; */ public class DocumentsOnlyRankProfile extends RankProfile { - public DocumentsOnlyRankProfile(String name, Search search, RankProfileRegistry rankProfileRegistry, + public DocumentsOnlyRankProfile(String name, Schema schema, RankProfileRegistry rankProfileRegistry, RankingConstants rankingConstants) { - super(name, search, rankProfileRegistry, rankingConstants); + super(name, schema, rankProfileRegistry, rankingConstants); } @Override diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/FieldOperationApplierForSearch.java b/config-model/src/main/java/com/yahoo/searchdefinition/FieldOperationApplierForSearch.java index 6460fdcdbc7..52110e95ac7 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/FieldOperationApplierForSearch.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/FieldOperationApplierForSearch.java @@ -14,8 +14,8 @@ public class FieldOperationApplierForSearch extends FieldOperationApplier { //Do nothing } - public void process(Search search) { - for (Field field : search.extraFieldList()) { + public void process(Schema schema) { + for (Field field : schema.extraFieldList()) { apply(field); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/FieldSets.java b/config-model/src/main/java/com/yahoo/searchdefinition/FieldSets.java index ba015ebaba6..065ade9b094 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/FieldSets.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/FieldSets.java @@ -4,19 +4,28 @@ package com.yahoo.searchdefinition; import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; import com.yahoo.searchdefinition.document.FieldSet; /** - * The field sets owned by a {@link Search} + * The field sets owned by a {@link Schema} * Both built in and user defined. * * @author vegardh */ public class FieldSets { - private final Map<String, FieldSet> userFieldSets = new LinkedHashMap<>(); - private final Map<String, FieldSet> builtInFieldSets = new LinkedHashMap<>(); + private final Optional<Schema> owner; + private final Map<String, FieldSet> userFieldSets; + private final Map<String, FieldSet> builtInFieldSets; + + public FieldSets(Optional<Schema> owner) { + this.owner = owner; + userFieldSets = new LinkedHashMap<>(); + builtInFieldSets = new LinkedHashMap<>(); + } /** * Adds an entry to user field sets, creating entries as needed @@ -48,12 +57,22 @@ public class FieldSets { /** Returns the built in field sets, unmodifiable */ public Map<String, FieldSet> builtInFieldSets() { - return Collections.unmodifiableMap(builtInFieldSets); + if (owner.isEmpty() || owner.get().inherited().isEmpty()) return Collections.unmodifiableMap(builtInFieldSets); + if (builtInFieldSets.isEmpty()) return owner.get().inherited().get().fieldSets().builtInFieldSets(); + + var fieldSets = new LinkedHashMap<>(owner.get().inherited().get().fieldSets().builtInFieldSets()); + fieldSets.putAll(builtInFieldSets); + return Collections.unmodifiableMap(fieldSets); } /** Returns the user defined field sets, unmodifiable */ public Map<String, FieldSet> userFieldSets() { - return Collections.unmodifiableMap(userFieldSets); + if (owner.isEmpty() || owner.get().inherited().isEmpty()) return Collections.unmodifiableMap(userFieldSets); + if (userFieldSets.isEmpty()) return owner.get().inherited().get().fieldSets().userFieldSets(); + + var fieldSets = new LinkedHashMap<>(owner.get().inherited().get().fieldSets().userFieldSets()); + fieldSets.putAll(userFieldSets); + return Collections.unmodifiableMap(fieldSets); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/ImmutableSearch.java b/config-model/src/main/java/com/yahoo/searchdefinition/ImmutableSchema.java index 605176e0c07..d0f958741fe 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/ImmutableSearch.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/ImmutableSchema.java @@ -12,17 +12,19 @@ import com.yahoo.vespa.documentmodel.SummaryField; import java.io.Reader; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.stream.Stream; /** - * An interface containing the non-mutating methods of {@link Search}. - * For description of the methods see {@link Search}. + * An interface containing the non-mutating methods of {@link Schema}. + * For description of the methods see {@link Schema}. * * @author bjorncs */ -public interface ImmutableSearch { +public interface ImmutableSchema { String getName(); + Optional<? extends ImmutableSchema> inherited(); Index getIndex(String name); ImmutableSDField getConcreteField(String name); //TODO split in mutating/immutable by returning List<ImmutableSDField> @@ -45,4 +47,5 @@ public interface ImmutableSearch { List<ImmutableSDField> allFieldsList(); Map<String, SummaryField> getSummaryFields(ImmutableSDField field); + } 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 25cdd1e08cd..a1248409368 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/ImportedFieldsEnumerator.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/ImportedFieldsEnumerator.java @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition; import com.yahoo.searchdefinition.document.SDDocumentType; -import java.util.List; +import java.util.Collection; /** * Enumerates and emplaces a set of all imported fields into a SDDocumentType from @@ -11,9 +11,9 @@ import java.util.List; */ public class ImportedFieldsEnumerator { - private final List<Search> schemas; + private final Collection<Schema> schemas; - public ImportedFieldsEnumerator(List<Search> schemas) { + public ImportedFieldsEnumerator(Collection<Schema> schemas) { this.schemas = schemas; } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/Index.java b/config-model/src/main/java/com/yahoo/searchdefinition/Index.java index bc1800f7ad7..793fcc59f9d 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/Index.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/Index.java @@ -88,11 +88,11 @@ public class Index implements Cloneable, Serializable { * Whether this field should be stemmed in this search definition, * this is never null */ - public Stemming getStemming(Search search) { + public Stemming getStemming(Schema schema) { if (stemming != null) return stemming; else - return search.getStemming(); + return schema.getStemming(); } /** diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/OnnxModels.java b/config-model/src/main/java/com/yahoo/searchdefinition/OnnxModels.java index 9c1ee2bb609..e249fe59f14 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/OnnxModels.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/OnnxModels.java @@ -8,6 +8,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Optional; /** * ONNX models tied to a search definition or global. @@ -16,11 +17,16 @@ import java.util.Map; */ public class OnnxModels { - private final Map<String, OnnxModel> models = new HashMap<>(); private final FileRegistry fileRegistry; - public OnnxModels(FileRegistry fileRegistry) { + /** The schema this belongs to, or empty if it is global */ + private final Optional<Schema> owner; + + private final Map<String, OnnxModel> models = new HashMap<>(); + + public OnnxModels(FileRegistry fileRegistry, Optional<Schema> owner) { this.fileRegistry = fileRegistry; + this.owner = owner; } public void add(OnnxModel model) { @@ -35,20 +41,34 @@ public class OnnxModels { } public OnnxModel get(String name) { - return models.get(name); + var model = models.get(name); + if (model != null) return model; + if (owner.isPresent() && owner.get().inherited().isPresent()) + return owner.get().inherited().get().onnxModels().get(name); + return null; } public boolean has(String name) { - return models.containsKey(name); + boolean has = models.containsKey(name); + if (has) return true; + if (owner.isPresent() && owner.get().inherited().isPresent()) + return owner.get().inherited().get().onnxModels().has(name); + return false; } public Map<String, OnnxModel> asMap() { - return Collections.unmodifiableMap(models); + // Shortcuts + if (owner.isEmpty() || owner.get().inherited().isEmpty()) return Collections.unmodifiableMap(models); + if (models.isEmpty()) return owner.get().inherited().get().onnxModels().asMap(); + + var allModels = new HashMap<>(owner.get().inherited().get().onnxModels().asMap()); + allModels.putAll(models); + return Collections.unmodifiableMap(allModels); } /** Initiate sending of these models to some services over file distribution */ public void sendTo(Collection<? extends AbstractService> services) { - models.values().forEach(model -> model.sendTo(services)); + asMap().values().forEach(model -> model.sendTo(services)); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java index 68faa462fdd..7f3b018d569 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java @@ -61,7 +61,7 @@ public class RankProfile implements Cloneable { private final String name; /** The search definition owning this profile, or null if global (owned by a model) */ - private final ImmutableSearch search; + private final ImmutableSchema search; /** The name of the rank profile inherited by this */ private String inheritedName = null; @@ -147,18 +147,18 @@ public class RankProfile implements Cloneable { * Creates a new rank profile for a particular search definition * * @param name the name of the new profile - * @param search the search definition owning this profile + * @param schema the search definition owning this profile * @param rankProfileRegistry the {@link com.yahoo.searchdefinition.RankProfileRegistry} to use for storing * and looking up rank profiles. */ - public RankProfile(String name, Search search, RankProfileRegistry rankProfileRegistry, RankingConstants rankingConstants) { + public RankProfile(String name, Schema schema, RankProfileRegistry rankProfileRegistry, RankingConstants rankingConstants) { this.name = Objects.requireNonNull(name, "name cannot be null"); - this.search = Objects.requireNonNull(search, "search cannot be null"); + this.search = Objects.requireNonNull(schema, "search cannot be null"); this.onnxModels = null; this.rankingConstants = rankingConstants; this.rankProfileRegistry = rankProfileRegistry; - this.applicationPackage = search.applicationPackage(); - this.deployLogger = search.getDeployLogger(); + this.applicationPackage = schema.applicationPackage(); + this.deployLogger = schema.getDeployLogger(); } /** @@ -166,7 +166,8 @@ public class RankProfile implements Cloneable { * * @param name the name of the new profile */ - public RankProfile(String name, ApplicationPackage applicationPackage, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, RankingConstants rankingConstants, OnnxModels onnxModels) { + public RankProfile(String name, ApplicationPackage applicationPackage, DeployLogger deployLogger, + RankProfileRegistry rankProfileRegistry, RankingConstants rankingConstants, OnnxModels onnxModels) { this.name = Objects.requireNonNull(name, "name cannot be null"); this.search = null; this.rankProfileRegistry = rankProfileRegistry; @@ -179,7 +180,7 @@ public class RankProfile implements Cloneable { public String getName() { return name; } /** Returns the search definition owning this, or null if it is global */ - public ImmutableSearch getSearch() { return search; } + public ImmutableSchema getSearch() { return search; } /** Returns the application this is part of */ public ApplicationPackage applicationPackage() { @@ -254,8 +255,8 @@ public class RankProfile implements Cloneable { } } - private RankProfile resolveInherited(ImmutableSearch search) { - SDDocumentType documentType = search.getDocument(); + private RankProfile resolveInherited(ImmutableSchema schema) { + SDDocumentType documentType = schema.getDocument(); if (documentType != null) { if (name.equals(inheritedName)) { // If you seemingly inherit yourself, you are actually referencing a rank-profile in one of your inherited schemas @@ -266,7 +267,7 @@ public class RankProfile implements Cloneable { } return rankProfileRegistry.resolve(documentType, inheritedName); } - return rankProfileRegistry.get(search.getName(), inheritedName); + return rankProfileRegistry.get(schema.getName(), inheritedName); } private RankProfile resolveInherited() { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfileRegistry.java b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfileRegistry.java index 52b9fba391b..4825da4087e 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfileRegistry.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfileRegistry.java @@ -14,7 +14,7 @@ import java.util.Map; import java.util.Set; /** - * Mapping from name to {@link RankProfile} as well as a reverse mapping of {@link RankProfile} to {@link Search}. + * Mapping from name to {@link RankProfile} as well as a reverse mapping of {@link RankProfile} to {@link Schema}. * Having both of these mappings consolidated here make it easier to remove dependencies on these mappings at * run time, since it is essentially only used when building rank profile config at deployment time. * @@ -30,14 +30,18 @@ public class RankProfileRegistry { /* These rank profiles can be overridden: 'default' rank profile, as that is documented to work. And 'unranked'. */ static final Set<String> overridableRankProfileNames = new HashSet<>(Arrays.asList("default", "unranked")); - public static RankProfileRegistry createRankProfileRegistryWithBuiltinRankProfiles(Search search) { + public RankProfileRegistry() { + + } + + public static RankProfileRegistry createRankProfileRegistryWithBuiltinRankProfiles(Schema schema) { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - rankProfileRegistry.add(new DefaultRankProfile(search, rankProfileRegistry, search.rankingConstants())); - rankProfileRegistry.add(new UnrankedRankProfile(search, rankProfileRegistry, search.rankingConstants())); + rankProfileRegistry.add(new DefaultRankProfile(schema, rankProfileRegistry, schema.rankingConstants())); + rankProfileRegistry.add(new UnrankedRankProfile(schema, rankProfileRegistry, schema.rankingConstants())); return rankProfileRegistry; } - private String extractName(ImmutableSearch search) { + private String extractName(ImmutableSchema search) { return search != null ? search.getName() : MAGIC_GLOBAL_RANKPROFILES; } @@ -69,17 +73,21 @@ public class RankProfileRegistry { /** * Returns a named rank profile, null if the search definition doesn't have one with the given name * - * @param search the {@link Search} that owns the rank profile. + * @param schema the {@link Schema} that owns the rank profile * @param name the name of the rank profile * @return the RankProfile to return. */ - public RankProfile get(String search, String name) { - Map<String, RankProfile> profiles = rankProfiles.get(search); + public RankProfile get(String schema, String name) { + Map<String, RankProfile> profiles = rankProfiles.get(schema); if (profiles == null) return null; return profiles.get(name); } - public RankProfile get(ImmutableSearch search, String name) { - return get(search.getName(), name); + + public RankProfile get(ImmutableSchema schema, String name) { + var profile = get(schema.getName(), name); + if (profile != null) return profile; + if (schema.inherited().isPresent()) return get(schema.inherited().get(), name); + return null; } public RankProfile getGlobal(String name) { @@ -129,7 +137,7 @@ public class RankProfileRegistry { * @param search search definition to fetch rank profiles for, or null for the global ones * @return Collection of RankProfiles */ - public Collection<RankProfile> rankProfilesOf(ImmutableSearch search) { + public Collection<RankProfile> rankProfilesOf(ImmutableSchema search) { return rankProfilesOf(extractName(search)); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/RankingConstants.java b/config-model/src/main/java/com/yahoo/searchdefinition/RankingConstants.java index 8df68b210ce..1e0eacaea16 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/RankingConstants.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankingConstants.java @@ -6,7 +6,9 @@ import com.yahoo.vespa.model.AbstractService; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.Map; +import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Function; @@ -18,11 +20,16 @@ import java.util.function.Function; */ public class RankingConstants { - private final Map<String, RankingConstant> constants = new ConcurrentHashMap<>(); private final FileRegistry fileRegistry; - public RankingConstants(FileRegistry fileRegistry) { + /** The schema this belongs to, or empty if it is global */ + private final Optional<Schema> owner; + + private final Map<String, RankingConstant> constants = new ConcurrentHashMap<>(); + + public RankingConstants(FileRegistry fileRegistry, Optional<Schema> owner) { this.fileRegistry = fileRegistry; + this.owner = owner; } public void add(RankingConstant constant) { @@ -33,12 +40,14 @@ public class RankingConstants { if ( prev != null ) throw new IllegalArgumentException("Ranking constant '" + name + "' defined twice"); } + public void putIfAbsent(RankingConstant constant) { constant.validate(); constant.register(fileRegistry); String name = constant.getName(); constants.putIfAbsent(name, constant); } + public void computeIfAbsent(String name, Function<? super String, ? extends RankingConstant> createConstant) { constants.computeIfAbsent(name, key -> { RankingConstant constant = createConstant.apply(key); @@ -50,16 +59,26 @@ public class RankingConstants { /** Returns the ranking constant with the given name, or null if not present */ public RankingConstant get(String name) { - return constants.get(name); + var constant = constants.get(name); + if (constant != null) return constant; + if (owner.isPresent() && owner.get().inherited().isPresent()) + return owner.get().inherited().get().rankingConstants().get(name); + return null; } /** Returns a read-only map of the ranking constants in this indexed by name */ public Map<String, RankingConstant> asMap() { - return Collections.unmodifiableMap(constants); + // Shortcuts + if (owner.isEmpty() || owner.get().inherited().isEmpty()) return Collections.unmodifiableMap(constants); + if (constants.isEmpty()) return owner.get().inherited().get().rankingConstants().asMap(); + + var allConstants = new HashMap<>(owner.get().inherited().get().rankingConstants().asMap()); + allConstants.putAll(constants); + return Collections.unmodifiableMap(allConstants); } /** Initiate sending of these constants to some services over file distribution */ public void sendTo(Collection<? extends AbstractService> services) { - constants.values().forEach(constant -> constant.sendTo(services)); + asMap().values().forEach(constant -> constant.sendTo(services)); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/Search.java b/config-model/src/main/java/com/yahoo/searchdefinition/Schema.java index 415fcd1d34e..b2d4f0592fe 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/Search.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/Schema.java @@ -7,6 +7,7 @@ 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.deploy.TestProperties; +import com.yahoo.document.DataTypeName; import com.yahoo.document.Field; import com.yahoo.searchdefinition.derived.SummaryClass; import com.yahoo.searchdefinition.document.Attribute; @@ -26,105 +27,125 @@ import java.io.Reader; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.TreeMap; import java.util.logging.Level; import java.util.stream.Stream; /** - * A search definition describes (or uses) some document types, defines how these are turned into a relevancy tuned - * index through indexing and how data from documents should be served at search time. The identity of this - * class is its name. + * A schema contains a document type, additional fields, rank profiles and document summaries. * * @author bratseth */ // TODO: Make a class owned by this, for each of these responsibilities: // Managing indexes, managing attributes, managing summary classes. // Ensure that after the processing step, all implicit instances of the above types are explicitly represented -public class Search implements ImmutableSearch { +public class Schema implements ImmutableSchema { private static final String SD_DOC_FIELD_NAME = "sddocname"; private static final List<String> RESERVED_NAMES = List.of( "index", "index_url", "summary", "attribute", "select_input", "host", SummaryClass.DOCUMENT_ID_FIELD, "position", "split_foreach", "tokenize", "if", "else", "switch", "case", SD_DOC_FIELD_NAME, "relevancy"); - /** Returns true if the given field name is a reserved name */ - public static boolean isReservedName(String name) { - return RESERVED_NAMES.contains(name); - } - - private final FieldSets fieldSets = new FieldSets(); - - /** The unique name of this search definition */ + /** The unique name of this schema */ private String name; + /** The name of the schema this should inherit all the content of, if any */ + private final Optional<String> inherited; + /** True if this doesn't define a search, just a document type */ private final boolean documentsOnly; - private boolean rawAsBase64 = false; + private Boolean rawAsBase64 = null; + + /** The stemming setting of this schema. Default is BEST. */ + private Stemming stemming = null; - /** The stemming setting of this search definition. Default is BEST. */ - private Stemming stemming = Stemming.BEST; + private final FieldSets fieldSets = new FieldSets(Optional.of(this)); - /** Documents contained in this definition */ - private SDDocumentType docType; + /** The document contained in this schema */ + private SDDocumentType documentType; - /** The extra fields of this search definition */ + /** The extra fields of this schema */ private final Map<String, SDField> fields = new LinkedHashMap<>(); - /** The explicitly defined indices of this search definition */ private final Map<String, Index> indices = new LinkedHashMap<>(); - /** The explicitly defined summaries of this search definition. _Must_ preserve order. */ + /** The explicitly defined summaries of this schema. _Must_ preserve order. */ private final Map<String, DocumentSummary> summaries = new LinkedHashMap<>(); /** External rank expression files of this */ private final LargeRankExpressions largeRankExpressions; - /** Ranking constants of this */ private final RankingConstants rankingConstants; - /** Onnx models of this */ private final OnnxModels onnxModels; - private Optional<TemporaryImportedFields> temporaryImportedFields = Optional.of(new TemporaryImportedFields()); + /** All imported fields of this (and parent schemas) */ + // TODO: Use empty, not optional + // TODO: Merge this and importedFields + private final Optional<TemporaryImportedFields> temporaryImportedFields = Optional.of(new TemporaryImportedFields(this)); + /** The resulting processed field */ private Optional<ImportedFields> importedFields = Optional.empty(); - private final ApplicationPackage applicationPackage; + private final Application owner; private final DeployLogger deployLogger; private final ModelContext.Properties properties; /** Testing only */ - public Search(String name) { - this(name, null, null, new BaseDeployLogger(), new TestProperties()); + public Schema(String name) { + this(name, Optional.empty(), null, null, new BaseDeployLogger(), new TestProperties()); } + + public Schema(String name, + Application application, + FileRegistry fileRegistry, + DeployLogger deployLogger, + ModelContext.Properties properties) { + this(name, Optional.empty(), application, fileRegistry, deployLogger, properties); + } + /** - * Creates a proper search definition + * Creates a schema * - * @param name of the the searchdefinition - * @param applicationPackage the application containing this + * @param name of the schema + * @param inherited the schema this inherits, if any + * @param application the application containing this */ - public Search(String name, ApplicationPackage applicationPackage, FileRegistry fileRegistry, DeployLogger deployLogger, ModelContext.Properties properties) { - this(applicationPackage, fileRegistry, deployLogger, properties, false); + public Schema(String name, + Optional<String> inherited, + Application application, + FileRegistry fileRegistry, + DeployLogger deployLogger, + ModelContext.Properties properties) { + this(inherited, application, fileRegistry, deployLogger, properties, false); this.name = name; } - protected Search(ApplicationPackage applicationPackage, FileRegistry fileRegistry, DeployLogger deployLogger, ModelContext.Properties properties) { - this(applicationPackage, fileRegistry, deployLogger, properties, true); + protected Schema(Application application, FileRegistry fileRegistry, DeployLogger deployLogger, ModelContext.Properties properties) { + this(Optional.empty(), application, fileRegistry, deployLogger, properties, true); } - private Search(ApplicationPackage applicationPackage, FileRegistry fileRegistry, DeployLogger deployLogger, ModelContext.Properties properties, boolean documentsOnly) { - this.applicationPackage = applicationPackage; + private Schema(Optional<String> inherited, + Application application, + FileRegistry fileRegistry, + DeployLogger deployLogger, + ModelContext.Properties properties, + boolean documentsOnly) { + this.inherited = inherited; + this.owner = application; this.deployLogger = deployLogger; this.properties = properties; this.documentsOnly = documentsOnly; largeRankExpressions = new LargeRankExpressions(fileRegistry); - rankingConstants = new RankingConstants(fileRegistry); - onnxModels = new OnnxModels(fileRegistry); + rankingConstants = new RankingConstants(fileRegistry, Optional.of(this)); + onnxModels = new OnnxModels(fileRegistry, Optional.of(this)); } protected void setName(String name) { @@ -136,22 +157,27 @@ public class Search implements ImmutableSearch { return name; } - /** - * Returns true if this doesn't define a search, just some documents - * - * @return if the searchdefinition only has documents - */ + /** Returns true if this only defines a document type, not a full schema */ public boolean isDocumentsOnly() { return documentsOnly; } + @Override + public Optional<Schema> inherited() { + return inherited.map(name -> owner.schemas().get(name)); + } + /** * Returns true if 'raw' fields shall be presented as base64 in summary - * Note that tis is temporary and will disappear on Vespa 8 as it will become default, and only option. + * Note that this is temporary and will disappear on Vespa 8 as it will become default, and only option. * * @return true if raw shall be encoded as base64 in summary */ - public boolean isRawAsBase64() { return rawAsBase64; } + public boolean isRawAsBase64() { + if (rawAsBase64 != null) return rawAsBase64; + if (inherited.isEmpty()) return false; + return requireInherited().isRawAsBase64(); + } public void enableRawAsBase64() { rawAsBase64 = true; } @@ -162,20 +188,14 @@ public class Search implements ImmutableSearch { * @throws NullPointerException if this is attempted set to null */ public void setStemming(Stemming stemming) { - if (stemming == null) { - throw new NullPointerException("The stemming setting of a search definition " + - "can not be null"); - } - this.stemming = stemming; + this.stemming = Objects.requireNonNull(stemming, "Stemming cannot be null"); } - /** - * Returns whether fields should be stemmed by default or not. Default is ALL. This is never null. - * - * @return the default stemming for this searchdefinition - */ + /** Returns whether fields should be stemmed by default or not. Default is BEST. This is never null. */ public Stemming getStemming() { - return stemming; + if (stemming != null) return stemming; + if (inherited.isEmpty()) return Stemming.BEST; + return requireInherited().getStemming(); } /** @@ -184,10 +204,10 @@ public class Search implements ImmutableSearch { * @param document the document type to add */ public void addDocument(SDDocumentType document) { - if (docType != null) { + if (documentType != null) { throw new IllegalArgumentException("Searchdefinition cannot have more than one document"); } - docType = document; + documentType = document; } @Override @@ -214,7 +234,6 @@ public class Search implements ImmutableSearch { } public void setImportedFields(ImportedFields importedFields) { - temporaryImportedFields = Optional.empty(); this.importedFields = Optional.of(importedFields); } @@ -240,7 +259,7 @@ public class Search implements ImmutableSearch { public List<ImmutableSDField> allFieldsList() { List<ImmutableSDField> all = new ArrayList<>(); all.addAll(extraFieldList()); - for (Field field : docType.fieldSet()) { + for (Field field : documentType.fieldSet()) { all.add((ImmutableSDField) field); } if (importedFields.isPresent()) { @@ -258,8 +277,8 @@ public class Search implements ImmutableSearch { * @return the contained or used document type, or null if there is no such document */ public SDDocumentType getDocument(String name) { - if (docType != null && name.equals(docType.getName())) { - return docType; + if (documentType != null && name.equals(documentType.getName())) { + return documentType; } return null; } @@ -268,7 +287,7 @@ public class Search implements ImmutableSearch { * @return true if the document has been added. */ public boolean hasDocument() { - return docType != null; + return documentType != null; } /** @@ -276,7 +295,7 @@ public class Search implements ImmutableSearch { */ @Override public SDDocumentType getDocument() { - return docType; + return documentType; } /** @@ -288,7 +307,7 @@ public class Search implements ImmutableSearch { public List<SDField> allConcreteFields() { List<SDField> allFields = new ArrayList<>(); allFields.addAll(extraFieldList()); - for (Field field : docType.fieldSet()) { + for (Field field : documentType.fieldSet()) { allFields.add((SDField)field); } return allFields; @@ -299,11 +318,16 @@ public class Search implements ImmutableSearch { */ @Override public Reader getRankingExpression(String fileName) { - return applicationPackage.getRankingExpression(fileName); + return owner.applicationPackage().getRankingExpression(fileName); } + public Application application() { return owner; } + @Override - public ApplicationPackage applicationPackage() { return applicationPackage; } + public ApplicationPackage applicationPackage() { + if (owner == null) return null; + return owner.applicationPackage(); + } @Override public DeployLogger getDeployLogger() { return deployLogger; } @@ -321,10 +345,9 @@ public class Search implements ImmutableSearch { @Override public SDField getConcreteField(String name) { SDField field = getExtraField(name); - if (field != null) { - return field; - } - return (SDField)docType.getField(name); + if (field != null) return field; + + return (SDField) documentType.getField(name); } /** @@ -335,7 +358,7 @@ public class Search implements ImmutableSearch { * @return The named field, or null if not found. */ public SDField getDocumentField(String name) { - return (SDField)docType.getField(name); + return (SDField) documentType.getField(name); } /** @@ -353,11 +376,17 @@ public class Search implements ImmutableSearch { } public Collection<SDField> extraFieldList() { - return fields.values(); + if (inherited.isEmpty()) return fields.values(); + var fields = new HashSet<>(requireInherited().extraFieldList()); + fields.addAll(this.fields.values()); + return fields; } + public Collection<SDField> allExtraFields() { Map<String, SDField> extraFields = new TreeMap<>(); - for (Field field : docType.fieldSet()) { + if (inherited.isPresent()) + requireInherited().allExtraFields().forEach(field -> extraFields.put(field.getName(), field)); + for (Field field : documentType.fieldSet()) { SDField sdField = (SDField) field; if (sdField.isExtraField()) { extraFields.put(sdField.getName(), sdField); @@ -376,7 +405,10 @@ public class Search implements ImmutableSearch { * @return the SDField of this name */ public SDField getExtraField(String fieldName) { - return fields.get(fieldName); + SDField field = fields.get(fieldName); + if (field != null) return field; + if (inherited.isEmpty()) return null; + return requireInherited().getExtraField(fieldName); } /** @@ -389,10 +421,9 @@ public class Search implements ImmutableSearch { } /** - * <p>Returns an index, or null if no index with this name has had some <b>explicit settings</b> applied. Even if - * this returns null, the index may be implicitly defined by an indexing statement.</p> - * <p>This will return the - * index whether it is defined on this search or on one of its fields</p> + * Returns an index, or null if no index with this name has had some <b>explicit settings</b> applied. Even if + * this returns null, the index may be implicitly defined by an indexing statement. This will return the + * index whether it is defined on this schema or on one of its fields. * * @param name the name of the index to get * @return the index requested @@ -400,34 +431,33 @@ public class Search implements ImmutableSearch { @Override public Index getIndex(String name) { List<Index> sameIndices = new ArrayList<>(1); - Index searchIndex = indices.get(name); - if (searchIndex != null) { - sameIndices.add(searchIndex); - } + + getSchemaIndex(name).ifPresent(sameIndices::add); for (ImmutableSDField field : allConcreteFields()) { - Index index = field.getIndex(name); - if (index != null) { - sameIndices.add(index); - } - } - if (sameIndices.size() == 0) { - return null; - } - if (sameIndices.size() == 1) { - return sameIndices.get(0); + if (field.getIndex(name) != null) + sameIndices.add(field.getIndex(name)); } + if (sameIndices.size() == 0) return null; + if (sameIndices.size() == 1) return sameIndices.get(0); return consolidateIndices(sameIndices); } + /** Returns the schema level index of this name, in this or any inherited schema, if any */ + Optional<Index> getSchemaIndex(String name) { + if (indices.containsKey(name)) return Optional.of(indices.get(name)); + if (inherited.isPresent()) return requireInherited().getSchemaIndex(name); + return Optional.empty(); + } + public boolean existsIndex(String name) { - if (indices.get(name) != null) { + if (indices.get(name) != null) + return true; + if (inherited.isPresent() && requireInherited().existsIndex(name)) return true; - } for (ImmutableSDField field : allConcreteFields()) { - if (field.existsIndex(name)) { + if (field.existsIndex(name)) return true; - } } return false; } @@ -435,7 +465,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. + * @param indices The list of indexes to consolidate * @return the consolidated index */ private Index consolidateIndices(List<Index> indices) { @@ -458,8 +488,8 @@ public class Search implements ImmutableSearch { !consolidated.getRankType().equals(current.getRankType())) { deployLogger.logApplicationPackage(Level.WARNING, "Conflicting rank type settings for " + - first.getName() + " in " + this + ", using " + - consolidated.getRankType()); + first.getName() + " in " + this + ", using " + + consolidated.getRankType()); } } @@ -470,19 +500,24 @@ public class Search implements ImmutableSearch { return consolidated; } - /** - * All explicitly defined indices, both on this search definition itself (returned first) and all its fields - * - * @return The list of explicit defined indexes. - */ + /** All explicitly defined indices, both on this schema itself (returned first) and all its fields */ @Override public List<Index> getExplicitIndices() { List<Index> allIndices = new ArrayList<>(indices.values()); + + if (inherited.isPresent()) { + for (Index inheritedIndex : requireInherited().getExplicitIndices()) { + if ( ! indices.containsKey(inheritedIndex.getName())) // child redefinitions shadows parents + allIndices.add(inheritedIndex); + } + } + for (ImmutableSDField field : allConcreteFields()) { for (Index index : field.getIndices().values()) { allIndices.add(index); } } + return Collections.unmodifiableList(allIndices); } @@ -503,7 +538,10 @@ public class Search implements ImmutableSearch { * @return Summary found. */ public DocumentSummary getSummary(String name) { - return summaries.get(name); + var summary = summaries.get(name); + if (summary != null) return summary; + if (inherited.isEmpty()) return null; + return requireInherited().getSummary(name); } /** @@ -520,47 +558,56 @@ public class Search implements ImmutableSearch { return summaryField; } } - return null; + if (inherited.isEmpty()) return null; + return requireInherited().getSummaryField(name); } /** * Returns the first explicit instance found of a summary field with this name, or null if not present explicitly in * any summary class * - * @param name Thge name of the explicit summary field to get. - * @return The SummaryField found. + * @param name the name of the explicit summary field to get. + * @return the SummaryField found. */ public SummaryField getExplicitSummaryField(String name) { for (DocumentSummary summary : summaries.values()) { SummaryField summaryField = summary.getSummaryField(name); - if (summaryField != null && !summaryField.isImplicit()) { + if (summaryField != null && !summaryField.isImplicit()) return summaryField; - } } - return null; + if (inherited.isEmpty()) return null; + return requireInherited().getExplicitSummaryField(name); } /** * Summaries defined by fields of this search definition. The default summary, named "default", is always the first * one in the returned iterator. - * - * @return The map of document summaries. */ public Map<String, DocumentSummary> getSummaries() { - return summaries; + // Shortcuts + if (inherited.isEmpty()) return summaries; + if (summaries.isEmpty()) return requireInherited().getSummaries(); + + var allSummaries = new LinkedHashMap<>(requireInherited().getSummaries()); + allSummaries.putAll(summaries); + return allSummaries; } + /** Returns the summaries defines in this only, not any that are inherited. */ + public Map<String, DocumentSummary> getSummariesInThis() { return Collections.unmodifiableMap(summaries); } + /** - * <p>Returns all summary fields, of all document summaries, which has the given field as source. If there are + * Returns all summary fields, of all document summaries, which has the given field as source. If there are * multiple summary fields with the same name, the last one will be used (they should all have the same content, if - * this is a valid search definition).</p> <p>The map gets owned by the receiver.</p> + * this is a valid search definition).The map becomes owned by the receiver. * - * @param field The source field. - * @return The map of summary fields found. + * @param field the source field + * @return the map of summary fields found */ @Override public Map<String, SummaryField> getSummaryFields(ImmutableSDField field) { - Map<String, SummaryField> summaryFields = new java.util.LinkedHashMap<>(); + Map<String, SummaryField> summaryFields = inherited.isPresent() ? requireInherited().getSummaryFields(field) + : new java.util.LinkedHashMap<>(); for (DocumentSummary documentSummary : summaries.values()) { for (SummaryField summaryField : documentSummary.getSummaryFields()) { if (summaryField.hasSource(field.getName())) { @@ -572,15 +619,14 @@ public class Search implements ImmutableSearch { } /** - * <p>Returns one summary field for each summary field name. If there are multiple summary fields with the same + * Returns one summary field for each summary field name. If there are multiple summary fields with the same * name, the last one will be used. Multiple fields of the same name should all have the same content in a valid * search definition, except from the destination set. So this method can be used for all summary handling except - * processing the destination set.</p> <p>The map gets owned by the receiver.</p> - * - * @return Map of unique summary fields + * processing the destination set. The map becomes owned by the receiver. */ public Map<String, SummaryField> getUniqueNamedSummaryFields() { - Map<String, SummaryField> summaryFields = new java.util.LinkedHashMap<>(); + Map<String, SummaryField> summaryFields = inherited.isPresent() ? requireInherited().getUniqueNamedSummaryFields() + : new java.util.LinkedHashMap<>(); for (DocumentSummary documentSummary : summaries.values()) { for (SummaryField summaryField : documentSummary.getSummaryFields()) { summaryFields.put(summaryField.getName(), summaryField); @@ -612,11 +658,11 @@ public class Search implements ImmutableSearch { @Override public boolean equals(Object o) { - if (!(o instanceof Search)) { + if (!(o instanceof Schema)) { return false; } - Search other = (Search)o; + Schema other = (Schema)o; return getName().equals(other.getName()); } @@ -651,8 +697,10 @@ public class Search implements ImmutableSearch { return false; } - /** The field set settings for this search */ - public FieldSets fieldSets() { return fieldSets; } + public FieldSets fieldSets() { return fieldSets; } + + /** Returns the schema inherited by this, or throws if none */ + private Schema requireInherited() { return owner.schemas().get(inherited.get()); } /** * For adding structs defined in document scope @@ -660,19 +708,36 @@ public class Search implements ImmutableSearch { * @param dt the struct to add * @return self, for chaining */ - public Search addType(SDDocumentType dt) { - docType.addType(dt); // TODO This is a very very dirty thing. It must go + public Schema addType(SDDocumentType dt) { + documentType.addType(dt); // TODO This is a very very dirty thing. It must go return this; } - public Search addAnnotation(SDAnnotationType dt) { - docType.addAnnotation(dt); + public Schema addAnnotation(SDAnnotationType dt) { + documentType.addAnnotation(dt); return this; } public void validate(DeployLogger logger) { + if (inherited.isPresent()) { + if (! owner.schemas().containsKey(inherited.get())) + throw new IllegalArgumentException(this + " inherits '" + inherited.get() + + "', but this schema does not exist"); + + // Require schema and document type inheritance to be consistent to keep things simple + // And require it to be explicit so we have the option to support other possibilities later + var parentDocument = owner.schemas().get(inherited.get()).getDocument(); + if ( ! getDocument().inheritedTypes().containsKey(new DataTypeName(parentDocument.getName()))) + throw new IllegalArgumentException(this + " inherits '" + inherited.get() + + "', but its document type does not inherit the parent's document type"); + } for (var summary : summaries.values()) summary.validate(logger); } + /** Returns true if the given field name is a reserved name */ + public static boolean isReservedName(String name) { + return RESERVED_NAMES.contains(name); + } + } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java b/config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java index 0f7ead43868..dc5ab752f31 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java @@ -21,6 +21,7 @@ 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; @@ -32,22 +33,24 @@ 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 Search} objects in an unambiguous way. The pattern for using this is to 1) Import + * 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 ApplicationPackage app; - private final RankProfileRegistry rankProfileRegistry; + private final Application application; private final QueryProfileRegistry queryProfileRegistry; private final FileRegistry fileRegistry; private final DeployLogger deployLogger; @@ -55,9 +58,11 @@ public class SearchBuilder { /** True to build the document aspect only, skipping instantiation of rank profiles */ private final boolean documentsOnly; - private List<Search> searchList = new LinkedList<>(); + private List<Schema> schemaList = new LinkedList<>(); private boolean isBuilt = false; + private final Set<Class<? extends Processor>> processorsToSkip = new HashSet<>(); + /** For testing only */ public SearchBuilder() { this(new RankProfileRegistry(), new QueryProfileRegistry()); @@ -109,15 +114,14 @@ public class SearchBuilder { QueryProfileRegistry queryProfileRegistry) { this(app, fileRegistry, deployLogger, properties, rankProfileRegistry, queryProfileRegistry, false); } - private SearchBuilder(ApplicationPackage app, + private SearchBuilder(ApplicationPackage applicationPackage, FileRegistry fileRegistry, DeployLogger deployLogger, ModelContext.Properties properties, RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfileRegistry, boolean documentsOnly) { - this.app = app; - this.rankProfileRegistry = rankProfileRegistry; + this.application = new Application(applicationPackage, rankProfileRegistry); this.queryProfileRegistry = queryProfileRegistry; this.fileRegistry = fileRegistry; this.deployLogger = deployLogger; @@ -169,8 +173,9 @@ public class SearchBuilder { private String importString(String str, String searchDefDir) throws ParseException { SimpleCharStream stream = new SimpleCharStream(str); try { - return importRawSearch(new SDParser(stream, fileRegistry, deployLogger, properties, app, rankProfileRegistry, documentsOnly) - .search(docTypeMgr, searchDefDir)); + 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) { @@ -180,24 +185,19 @@ public class SearchBuilder { /** * Registers the given search object to the internal list of objects to be processed during {@link #build()}. A - * {@link Search} object is considered to be "raw" if it has not already been processed. This is the case for most + * {@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 rawSearch the object to import. + * @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(Search rawSearch) { - if (rawSearch.getName() == null) - throw new IllegalArgumentException("Search has no name."); - String rawName = rawSearch.getName(); - for (Search search : searchList) { - if (rawName.equals(search.getName())) { - throw new IllegalArgumentException("A search definition with a search section called '" + rawName + - "' has already been added."); - } - } - searchList.add(rawSearch); + 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; } @@ -223,14 +223,14 @@ public class SearchBuilder { if (isBuilt) throw new IllegalStateException("Model already built"); if (validate) - searchList.forEach(search -> search.validate(deployLogger)); + application.validate(deployLogger); - List<Search> built = new ArrayList<>(); + List<Schema> built = new ArrayList<>(); List<SDDocumentType> sdocs = new ArrayList<>(); sdocs.add(SDDocumentType.VESPA_DOCUMENT); - for (Search search : searchList) { - if (search.hasDocument()) { - sdocs.add(search.getDocument()); + for (Schema schema : schemaList) { + if (schema.hasDocument()) { + sdocs.add(schema.getDocument()); } } @@ -241,51 +241,56 @@ public class SearchBuilder { new FieldOperationApplier().process(sdoc); } - var resolver = new DocumentReferenceResolver(searchList); + var resolver = new DocumentReferenceResolver(schemaList); sdocs.forEach(resolver::resolveReferences); sdocs.forEach(resolver::resolveInheritedReferences); - var importedFieldsEnumerator = new ImportedFieldsEnumerator(searchList); + var importedFieldsEnumerator = new ImportedFieldsEnumerator(schemaList); sdocs.forEach(importedFieldsEnumerator::enumerateImportedFields); if (validate) new DocumentGraphValidator().validateDocumentGraph(sdocs); var builder = new DocumentModelBuilder(model); - for (Search search : new SearchOrderer().order(searchList)) { - new FieldOperationApplierForSearch().process(search); // TODO: Why is this not in the regular list? - process(search, new QueryProfiles(queryProfileRegistry, deployLogger), validate); - built.add(search); + 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(searchList); + builder.addToModel(schemaList); if ( validate && ! builder.valid() ) throw new IllegalArgumentException("Impossible to build a correct model"); - searchList = built; + schemaList = built; isBuilt = true; } + /** Returns a modifiable set of processors we should skip for these schemas. Useful for testing. */ + public Set<Class<? extends Processor>> processorsToSkip() { return processorsToSkip; } + /** - * Processes and returns the given {@link Search} object. This method has been factored out of the {@link + * 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(Search search, QueryProfiles queryProfiles, boolean validate) { - new Processing().process(search, deployLogger, rankProfileRegistry, queryProfiles, validate, documentsOnly); + 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 Search} object + * 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 Search getSearch() { + public Schema getSearch() { if ( ! isBuilt) throw new IllegalStateException("Searches not built."); - if (searchList.size() != 1) - throw new IllegalStateException("This call only works if we have 1 search definition. Search definitions: " + searchList); + if (application.schemas().size() != 1) + throw new IllegalStateException("This call only works if we have 1 schema. Schemas: " + + application.schemas().values()); - return searchList.get(0); + return application.schemas().values().stream().findAny().get(); } public DocumentModel getModel() { @@ -293,7 +298,7 @@ public class SearchBuilder { } /** - * Returns the built {@link Search} object that has the given name. If the name is unknown, this method will simply + * 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, @@ -301,26 +306,25 @@ public class SearchBuilder { * @return the built object, or null if none with this name * @throws IllegalStateException if {@link #build()} has not been called. */ - public Search getSearch(String name) { + public Schema getSearch(String name) { if ( ! isBuilt) throw new IllegalStateException("Searches not built."); if (name == null) return getSearch(); - - for (Search search : searchList) - if (search.getName().equals(name)) return search; - return null; + return application.schemas().get(name); } + public Application application() { return application; } + /** - * Convenience method to return a list of all built {@link Search} objects. + * Convenience method to return a list of all built {@link Schema} objects. * - * @return The list of built searches. + * @return the list of built searches */ - public List<Search> getSearchList() { - return new ArrayList<>(searchList); + public List<Schema> getSearchList() { + return new ArrayList<>(schemaList); } /** - * Convenience factory method to import and build a {@link Search} object from a string. + * 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. @@ -346,7 +350,7 @@ public class SearchBuilder { } /** - * Convenience factory method to import and build a {@link Search} object from a file. Only for testing. + * 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 @@ -373,7 +377,7 @@ public class SearchBuilder { } /** - * Convenience factory method to import and build a {@link Search} object from a file. + * 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. @@ -414,6 +418,7 @@ public class SearchBuilder { 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()); } @@ -430,7 +435,8 @@ public class SearchBuilder { ModelContext.Properties properties, RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfileRegistry) throws IOException, ParseException { - return createFromDirectory(dir, MockApplicationPackage.fromSearchDefinitionDirectory(dir), fileRegistry, logger, properties, rankProfileRegistry, queryProfileRegistry); + return createFromDirectory(dir, MockApplicationPackage.fromSearchDefinitionAndRootDirectory(dir), fileRegistry, logger, properties, + rankProfileRegistry, queryProfileRegistry); } private static SearchBuilder createFromDirectory(String dir, @@ -462,27 +468,27 @@ public class SearchBuilder { // TODO: The build methods below just call the create methods above - remove /** - * Convenience factory method to import and build a {@link Search} object from a file. Only for testing. + * 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 Search} object. + * @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 Search buildFromFile(String fileName) throws IOException, ParseException { + 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 Search} object from a file. + * 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 Search} object. + * @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 Search buildFromFile(String fileName, + public static Schema buildFromFile(String fileName, RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfileRegistry) throws IOException, ParseException { @@ -490,16 +496,16 @@ public class SearchBuilder { } /** - * Convenience factory method to import and build a {@link Search} object from a file. + * 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 Search} object. + * @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 Search buildFromFile(String fileName, + public static Schema buildFromFile(String fileName, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfileRegistry) @@ -508,36 +514,36 @@ public class SearchBuilder { } /** - * Convenience factory method to import and build a {@link Search} object from a raw object. + * Convenience factory method to import and build a {@link Schema} object from a raw object. * - * @param rawSearch the raw object to build from. + * @param rawSchema the raw object to build from. * @return the built {@link SearchBuilder} object. - * @see #importRawSearch(Search) + * @see #importRawSearch(Schema) */ - public static SearchBuilder createFromRawSearch(Search rawSearch, + public static SearchBuilder createFromRawSearch(Schema rawSchema, RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfileRegistry) { SearchBuilder builder = new SearchBuilder(rankProfileRegistry, queryProfileRegistry); - builder.importRawSearch(rawSearch); + builder.importRawSearch(rawSchema); builder.build(); return builder; } /** - * Convenience factory method to import and build a {@link Search} object from a raw object. + * Convenience factory method to import and build a {@link Schema} object from a raw object. * - * @param rawSearch The raw object to build from. - * @return The built {@link Search} object. - * @see #importRawSearch(Search) + * @param rawSchema The raw object to build from. + * @return The built {@link Schema} object. + * @see #importRawSearch(Schema) */ - public static Search buildFromRawSearch(Search rawSearch, + public static Schema buildFromRawSearch(Schema rawSchema, RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfileRegistry) { - return createFromRawSearch(rawSearch, rankProfileRegistry, queryProfileRegistry).getSearch(); + return createFromRawSearch(rawSchema, rankProfileRegistry, queryProfileRegistry).getSearch(); } public RankProfileRegistry getRankProfileRegistry() { - return rankProfileRegistry; + return application.rankProfileRegistry(); } public QueryProfileRegistry getQueryProfileRegistry() { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/UnrankedRankProfile.java b/config-model/src/main/java/com/yahoo/searchdefinition/UnrankedRankProfile.java index 6bd30538abd..acf034362ca 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/UnrankedRankProfile.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/UnrankedRankProfile.java @@ -11,8 +11,8 @@ import com.yahoo.searchlib.rankingexpression.parser.ParseException; */ public class UnrankedRankProfile extends RankProfile { - public UnrankedRankProfile(Search search, RankProfileRegistry rankProfileRegistry, RankingConstants rankingConstants) { - super("unranked", search, rankProfileRegistry, rankingConstants); + public UnrankedRankProfile(Schema schema, RankProfileRegistry rankProfileRegistry, RankingConstants rankingConstants) { + super("unranked", schema, rankProfileRegistry, rankingConstants); try { RankingExpression exp = new RankingExpression("value(0)"); this.setFirstPhaseRanking(exp); diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/AttributeFields.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/AttributeFields.java index 24cc15dde21..67ed37800f9 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/AttributeFields.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/AttributeFields.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.config.subscription.ConfigInstanceUtil; import com.yahoo.document.DataType; import com.yahoo.document.PositionDataType; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.document.Case; import com.yahoo.searchdefinition.document.Dictionary; @@ -44,14 +44,14 @@ public class AttributeFields extends Derived implements AttributesConfig.Produce public static final AttributeFields empty = new AttributeFields(null); - public AttributeFields(Search search) { - if (search != null) - derive(search); + public AttributeFields(Schema schema) { + if (schema != null) + derive(schema); } /** Derives everything from a field */ @Override - protected void derive(ImmutableSDField field, Search search) { + protected void derive(ImmutableSDField field, Schema schema) { if (unsupportedFieldType(field)) { return; // Ignore complex struct and map fields for indexed search (only supported for streaming search) } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/Derived.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/Derived.java index fded9502c49..30cb236984d 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/Derived.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/Derived.java @@ -6,7 +6,7 @@ import com.yahoo.config.ConfigInstance.Builder; import com.yahoo.document.Field; import com.yahoo.io.IOUtils; import com.yahoo.searchdefinition.Index; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; @@ -36,14 +36,14 @@ public abstract class Derived implements Exportable { * and derive(SDField) for each search definition level field * AND sets the name of this to the name of the input search definition */ - protected void derive(Search search) { - setName(search.getName()); - derive(search.getDocument(), search); - for (Index index : search.getExplicitIndices()) - derive(index, search); - for (SDField field : search.allExtraFields()) - derive(field, search); - search.allImportedFields().forEach(importedField -> derive(importedField, search)); + protected void derive(Schema schema) { + setName(schema.getName()); + derive(schema.getDocument(), schema); + for (Index index : schema.getExplicitIndices()) + derive(index, schema); + for (SDField field : schema.allExtraFields()) + derive(field, schema); + schema.allImportedFields().forEach(importedField -> derive(importedField, schema)); } @@ -51,11 +51,11 @@ public abstract class Derived implements Exportable { * Derives the content of this configuration. This * default calls derive(SDField) for each document field */ - protected void derive(SDDocumentType document, Search search) { + protected void derive(SDDocumentType document, Schema schema) { for (Field field : document.fieldSet()) { SDField sdField = (SDField) field; if ( ! sdField.isExtraField()) { - derive(sdField, search); + derive(sdField, schema); } } } @@ -64,13 +64,13 @@ public abstract class Derived implements Exportable { * Derives the content of this configuration. This * default does nothing. */ - protected void derive(ImmutableSDField field, Search search) {} + protected void derive(ImmutableSDField field, Schema schema) {} /** * Derives the content of this configuration. This * default does nothing. */ - protected void derive(Index index, Search search) { + protected void derive(Index index, Schema schema) { } protected abstract String getDerivedName(); diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/DerivedConfiguration.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/DerivedConfiguration.java index 65bda6eb576..54e9a4ccb61 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/DerivedConfiguration.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/DerivedConfiguration.java @@ -14,7 +14,7 @@ import com.yahoo.io.IOUtils; import com.yahoo.protect.Validator; import com.yahoo.search.query.profile.QueryProfileRegistry; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.derived.validation.Validation; import com.yahoo.vespa.model.container.search.QueryProfiles; @@ -30,7 +30,7 @@ import java.util.concurrent.ExecutorService; */ public class DerivedConfiguration { - private final Search search; + private final Schema schema; private Summaries summaries; private SummaryMap summaryMap; private Juniperrc juniperrc; @@ -48,23 +48,23 @@ public class DerivedConfiguration { * Creates a complete derived configuration from a search definition. * Only used in tests. * - * @param search the search to derive a configuration from. Derived objects will be snapshots, but this argument is + * @param schema the search to derive a configuration from. Derived objects will be snapshots, but this argument is * live. Which means that this object will be inconsistent when the given search definition is later * modified. * @param rankProfileRegistry a {@link com.yahoo.searchdefinition.RankProfileRegistry} */ - public DerivedConfiguration(Search search, RankProfileRegistry rankProfileRegistry) { - this(search, rankProfileRegistry, new QueryProfileRegistry()); + public DerivedConfiguration(Schema schema, RankProfileRegistry rankProfileRegistry) { + this(schema, rankProfileRegistry, new QueryProfileRegistry()); } - DerivedConfiguration(Search search, RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfiles) { - this(search, new BaseDeployLogger(), new TestProperties(), rankProfileRegistry, queryProfiles, new ImportedMlModels(), new InThreadExecutorService()); + DerivedConfiguration(Schema schema, RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfiles) { + this(schema, new BaseDeployLogger(), new TestProperties(), rankProfileRegistry, queryProfiles, new ImportedMlModels(), new InThreadExecutorService()); } /** * Creates a complete derived configuration snapshot from a search definition. * - * @param search the search to derive a configuration from. Derived objects will be snapshots, but this + * @param schema the search to derive a configuration from. Derived objects will be snapshots, but this * argument is live. Which means that this object will be inconsistent when the given * search definition is later modified. * @param deployLogger a {@link DeployLogger} for logging when doing operations on this @@ -72,34 +72,34 @@ public class DerivedConfiguration { * @param rankProfileRegistry a {@link com.yahoo.searchdefinition.RankProfileRegistry} * @param queryProfiles the query profiles of this application */ - public DerivedConfiguration(Search search, + public DerivedConfiguration(Schema schema, DeployLogger deployLogger, ModelContext.Properties deployProperties, RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfiles, ImportedMlModels importedModels, ExecutorService executor) { - Validator.ensureNotNull("Search definition", search); - this.search = search; + Validator.ensureNotNull("Search definition", schema); + this.schema = schema; this.queryProfiles = queryProfiles; - if ( ! search.isDocumentsOnly()) { - streamingFields = new VsmFields(search); - streamingSummary = new VsmSummary(search); + if ( ! schema.isDocumentsOnly()) { + streamingFields = new VsmFields(schema); + streamingSummary = new VsmSummary(schema); } - if ( ! search.isDocumentsOnly()) { - attributeFields = new AttributeFields(search); - summaries = new Summaries(search, deployLogger); - summaryMap = new SummaryMap(search); - juniperrc = new Juniperrc(search); - rankProfileList = new RankProfileList(search, search.rankingConstants(), search.rankExpressionFiles(), - search.onnxModels(), attributeFields, rankProfileRegistry, + if ( ! schema.isDocumentsOnly()) { + attributeFields = new AttributeFields(schema); + summaries = new Summaries(schema, deployLogger); + summaryMap = new SummaryMap(schema); + juniperrc = new Juniperrc(schema); + rankProfileList = new RankProfileList(schema, schema.rankingConstants(), schema.rankExpressionFiles(), + schema.onnxModels(), attributeFields, rankProfileRegistry, queryProfiles, importedModels, deployProperties, executor); - indexingScript = new IndexingScript(search); - indexInfo = new IndexInfo(search); - indexSchema = new IndexSchema(search); - importedFields = new ImportedFields(search); + indexingScript = new IndexingScript(schema); + indexInfo = new IndexInfo(schema); + indexSchema = new IndexSchema(schema); + importedFields = new ImportedFields(schema); } - Validation.validate(this, search); + Validation.validate(this, schema); } /** @@ -109,7 +109,7 @@ public class DerivedConfiguration { * @throws IOException if exporting fails, some files may still be created */ public void export(String toDirectory) throws IOException { - if (!search.isDocumentsOnly()) { + if (!schema.isDocumentsOnly()) { summaries.export(toDirectory); summaryMap.export(toDirectory); juniperrc.export(toDirectory); @@ -171,8 +171,8 @@ public class DerivedConfiguration { this.indexingScript = script; } - public Search getSearch() { - return search; + public Schema getSearch() { + return schema; } public RankProfileList getRankProfileList() { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/ImportedFields.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/ImportedFields.java index 281ab6536bd..a63b88f9445 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/ImportedFields.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/ImportedFields.java @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.document.DataType; import com.yahoo.document.PositionDataType; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.searchdefinition.document.ImportedComplexField; @@ -25,13 +25,13 @@ public class ImportedFields extends Derived implements ImportedFieldsConfig.Prod private Optional<com.yahoo.searchdefinition.document.ImportedFields> importedFields = Optional.empty(); - public ImportedFields(Search search) { - derive(search); + public ImportedFields(Schema schema) { + derive(schema); } @Override - protected void derive(Search search) { - importedFields = search.importedFields(); + protected void derive(Schema schema) { + importedFields = schema.importedFields(); } @Override diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexInfo.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexInfo.java index 7950cd758fd..879ad570c26 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexInfo.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexInfo.java @@ -10,7 +10,7 @@ import com.yahoo.document.PositionDataType; import com.yahoo.document.PrimitiveDataType; import com.yahoo.document.StructuredDataType; import com.yahoo.searchdefinition.Index; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.document.BooleanIndexDefinition; import com.yahoo.searchdefinition.document.Case; @@ -55,33 +55,33 @@ public class IndexInfo extends Derived implements IndexInfoConfig.Producer { private final Set<IndexCommand> commands = new java.util.LinkedHashSet<>(); private final Map<String, String> aliases = new java.util.LinkedHashMap<>(); private final Map<String, FieldSet> fieldSets; - private Search search; + private Schema schema; - public IndexInfo(Search search) { - this.fieldSets = search.fieldSets().userFieldSets(); + public IndexInfo(Schema schema) { + this.fieldSets = schema.fieldSets().userFieldSets(); addIndexCommand("sddocname", CMD_INDEX); addIndexCommand("sddocname", CMD_WORD); - derive(search); + derive(schema); } @Override - protected void derive(Search search) { - super.derive(search); // Derive per field - this.search = search; + protected void derive(Schema schema) { + super.derive(schema); // Derive per field + this.schema = schema; // Populate fieldsets with actual field objects, bit late to do that here but for (FieldSet fs : fieldSets.values()) { for (String fieldName : fs.getFieldNames()) { - fs.fields().add(search.getField(fieldName)); + fs.fields().add(schema.getField(fieldName)); } } // Must follow, because index settings overrides field settings - for (Index index : search.getExplicitIndices()) { - derive(index, search); + for (Index index : schema.getExplicitIndices()) { + derive(index, schema); } // Commands for summary fields // TODO: Move to fieldinfo and implement differently. This is not right - for (SummaryField summaryField : search.getUniqueNamedSummaryFields().values()) { + for (SummaryField summaryField : schema.getUniqueNamedSummaryFields().values()) { if (summaryField.getTransform().isTeaser()) { addIndexCommand(summaryField.getName(), CMD_DYNTEASER); } @@ -100,11 +100,11 @@ public class IndexInfo extends Derived implements IndexInfoConfig.Producer { } @Override - protected void derive(ImmutableSDField field, Search search) { - derive(field, search, false); + protected void derive(ImmutableSDField field, Schema schema) { + derive(field, schema, false); } - protected void derive(ImmutableSDField field, Search search, boolean inPosition) { + protected void derive(ImmutableSDField field, Schema schema, boolean inPosition) { if (field.getDataType().equals(DataType.PREDICATE)) { addIndexCommand(field, CMD_PREDICATE); Index index = field.getIndex(field.getName()); @@ -127,7 +127,7 @@ public class IndexInfo extends Derived implements IndexInfoConfig.Producer { boolean isPosition = isPositionField(field); if (field.usesStructOrMap()) { for (ImmutableSDField structField : field.getStructFields()) { - derive(structField, search, isPosition); // Recursion + derive(structField, schema, isPosition); // Recursion } } @@ -151,8 +151,8 @@ public class IndexInfo extends Derived implements IndexInfoConfig.Producer { if (attribute != null && attribute.isFastSearch()) addIndexCommand(field.getName(), CMD_FAST_SEARCH); } else if (field.doesIndexing()) { - if (stemSomehow(field, search)) { - addIndexCommand(field, stemCmd(field, search), new StemmingOverrider(this, search)); + if (stemSomehow(field, schema)) { + addIndexCommand(field, stemCmd(field, schema), new StemmingOverrider(this, schema)); } if (normalizeAccents(field)) { addIndexCommand(field, CMD_NORMALIZE); @@ -201,12 +201,12 @@ public class IndexInfo extends Derived implements IndexInfoConfig.Producer { && field.getMatching().getCase().equals(Case.UNCASED)); } - static String stemCmd(ImmutableSDField field, Search search) { - return CMD_STEM + ":" + field.getStemming(search).toStemMode(); + static String stemCmd(ImmutableSDField field, Schema schema) { + return CMD_STEM + ":" + field.getStemming(schema).toStemMode(); } - private boolean stemSomehow(ImmutableSDField field, Search search) { - if (field.getStemming(search).equals(Stemming.NONE)) return false; + private boolean stemSomehow(ImmutableSDField field, Schema schema) { + if (field.getStemming(schema).equals(Stemming.NONE)) return false; return isTypeOrNested(field, DataType.STRING); } @@ -456,7 +456,7 @@ public class IndexInfo extends Derived implements IndexInfoConfig.Producer { } private Stemming getEffectiveStemming(ImmutableSDField field) { - Stemming active = field.getStemming(search); + Stemming active = field.getStemming(schema); if (field.getIndex(field.getName()) != null) { if (field.getIndex(field.getName()).getStemming()!=null) { active = field.getIndex(field.getName()).getStemming(); @@ -472,7 +472,7 @@ public class IndexInfo extends Derived implements IndexInfoConfig.Producer { if (field.getStemming() != null) { return !field.getStemming().equals(Stemming.NONE); } - if (search.getStemming()==Stemming.NONE) return false; + if (schema.getStemming() == Stemming.NONE) return false; if (field.isImportedField()) return false; if (field.getIndex(field.getName())==null) return true; if (field.getIndex(field.getName()).getStemming()==null) return true; @@ -563,19 +563,19 @@ public class IndexInfo extends Derived implements IndexInfoConfig.Producer { private static class StemmingOverrider extends IndexOverrider { - private Search search; + private Schema schema; - public StemmingOverrider(IndexInfo owner, Search search) { + public StemmingOverrider(IndexInfo owner, Schema schema) { super(owner); - this.search = search; + this.schema = schema; } public boolean override(String indexName, String command, ImmutableSDField field) { - if (search == null) { + if (schema == null) { return false; } - Index index = search.getIndex(indexName); + Index index = schema.getIndex(indexName); if (index == null) { return false; } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexSchema.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexSchema.java index 8b5e9d4ca8e..ce5731bcdeb 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexSchema.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexSchema.java @@ -7,7 +7,7 @@ import com.yahoo.document.Field; import com.yahoo.document.StructuredDataType; import com.yahoo.document.TensorDataType; import com.yahoo.document.WeightedSetDataType; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.BooleanIndexDefinition; import com.yahoo.searchdefinition.document.FieldSet; import com.yahoo.searchdefinition.document.ImmutableSDField; @@ -31,9 +31,9 @@ public class IndexSchema extends Derived implements IndexschemaConfig.Producer { private final Map<String, FieldCollection> collections = new LinkedHashMap<>(); private final Map<String, FieldSet> fieldSets = new LinkedHashMap<>(); - public IndexSchema(Search search) { - fieldSets.putAll(search.fieldSets().userFieldSets()); - derive(search); + public IndexSchema(Schema schema) { + fieldSets.putAll(schema.fieldSets().userFieldSets()); + derive(schema); } public boolean containsField(String fieldName) { @@ -41,15 +41,15 @@ public class IndexSchema extends Derived implements IndexschemaConfig.Producer { } @Override - protected void derive(Search search) { - super.derive(search); + protected void derive(Schema schema) { + super.derive(schema); } private boolean isTensorField(ImmutableSDField field) { return field.getDataType() instanceof TensorDataType; } - private void deriveIndexFields(ImmutableSDField field, Search search) { + private void deriveIndexFields(ImmutableSDField field, Schema schema) { // Note: Indexes for tensor fields are NOT part of the index schema for text fields. if ((!field.doesIndexing() && !field.isIndexStructureField()) || isTensorField(field)) @@ -62,7 +62,7 @@ public class IndexSchema extends Derived implements IndexschemaConfig.Producer { } String fieldName = field.getName(); for (Field flatField : lst) { - deriveIndexFields(flatField, search); + deriveIndexFields(flatField, schema); } if (lst.size() > 1) { FieldSet fieldSet = new FieldSet(fieldName); @@ -73,9 +73,9 @@ public class IndexSchema extends Derived implements IndexschemaConfig.Producer { } } - private void deriveIndexFields(Field field, Search search) { + private void deriveIndexFields(Field field, Schema schema) { IndexField toAdd = new IndexField(field.getName(), Index.convertType(field.getDataType()), field.getDataType()); - com.yahoo.searchdefinition.Index definedIndex = search.getIndex(field.getName()); + com.yahoo.searchdefinition.Index definedIndex = schema.getIndex(field.getName()); if (definedIndex != null) { toAdd.setIndexSettings(definedIndex); } @@ -98,11 +98,11 @@ public class IndexSchema extends Derived implements IndexschemaConfig.Producer { } @Override - protected void derive(ImmutableSDField field, Search search) { + protected void derive(ImmutableSDField field, Schema schema) { if (field.usesStructOrMap()) { return; // unsupported } - deriveIndexFields(field, search); + deriveIndexFields(field, schema); } @Override diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexingScript.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexingScript.java index 4bf4b21eb75..cabe8d001bd 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexingScript.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/IndexingScript.java @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.document.DataType; import com.yahoo.document.PositionDataType; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.vespa.configdefinition.IlscriptsConfig; import com.yahoo.vespa.configdefinition.IlscriptsConfig.Ilscript.Builder; @@ -39,20 +39,20 @@ public final class IndexingScript extends Derived implements IlscriptsConfig.Pro private final List<Expression> expressions = new ArrayList<>(); private List<ImmutableSDField> fieldsSettingLanguage; - public IndexingScript(Search search) { - derive(search); + public IndexingScript(Schema schema) { + derive(schema); } @Override - protected void derive(Search search) { - fieldsSettingLanguage = fieldsSettingLanguage(search); + protected void derive(Schema schema) { + fieldsSettingLanguage = fieldsSettingLanguage(schema); if (fieldsSettingLanguage.size() == 1) // Assume this language should be used for all fields addExpression(fieldsSettingLanguage.get(0).getIndexingScript()); - super.derive(search); + super.derive(schema); } @Override - protected void derive(ImmutableSDField field, Search search) { + protected void derive(ImmutableSDField field, Schema schema) { if (field.isImportedField()) return; if (field.hasFullIndexingDocprocRights()) @@ -75,11 +75,11 @@ public final class IndexingScript extends Derived implements IlscriptsConfig.Pro expressions.add(new StatementExpression(new ClearStateExpression(), new GuardExpression(expression))); } - private List<ImmutableSDField> fieldsSettingLanguage(Search search) { - return search.allFieldsList().stream() - .filter(field -> ! field.isImportedField()) - .filter(field -> field.containsExpression(SetLanguageExpression.class)) - .collect(Collectors.toList()); + private List<ImmutableSDField> fieldsSettingLanguage(Schema schema) { + return schema.allFieldsList().stream() + .filter(field -> ! field.isImportedField()) + .filter(field -> field.containsExpression(SetLanguageExpression.class)) + .collect(Collectors.toList()); } public Iterable<Expression> expressions() { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/Juniperrc.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/Juniperrc.java index 8dad49f40d1..327d7df4d07 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/Juniperrc.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/Juniperrc.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.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.vespa.documentmodel.SummaryField; import com.yahoo.vespa.documentmodel.SummaryTransform; import com.yahoo.vespa.config.search.summary.JuniperrcConfig; @@ -20,19 +20,19 @@ public class Juniperrc extends Derived implements JuniperrcConfig.Producer { /** * Constructs a new juniper rc instance for a given search object. This will derive the configuration automatically, - * so there is no need to call {@link #derive(com.yahoo.searchdefinition.Search)}. + * so there is no need to call {@link #derive(Schema)}. * - * @param search The search model to use for deriving. + * @param schema The search model to use for deriving. */ - public Juniperrc(Search search) { - derive(search); + public Juniperrc(Schema schema) { + derive(schema); } // Inherit doc from Derived. @Override - protected void derive(Search search) { - super.derive(search); - for (SummaryField summaryField : search.getUniqueNamedSummaryFields().values()) { + protected void derive(Schema schema) { + super.derive(schema); + for (SummaryField summaryField : schema.getUniqueNamedSummaryFields().values()) { if (summaryField.getTransform() == SummaryTransform.BOLDED) { boldingFields.add(summaryField.getName()); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java index dc84e1fdd8a..faee6d67dbf 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java @@ -12,7 +12,7 @@ import com.yahoo.searchdefinition.RankingConstant; import com.yahoo.searchdefinition.RankingConstants; import com.yahoo.vespa.config.search.RankProfilesConfig; import com.yahoo.searchdefinition.RankProfile; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.vespa.config.search.core.OnnxModelsConfig; import com.yahoo.vespa.config.search.core.RankingConstantsConfig; import com.yahoo.vespa.config.search.core.RankingExpressionsConfig; @@ -23,13 +23,14 @@ import java.util.Collection; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import java.util.logging.Logger; /** - * The derived rank profiles of a search definition + * The derived rank profiles of a schema * * @author bratseth */ @@ -45,18 +46,18 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ public static RankProfileList empty = new RankProfileList(); private RankProfileList() { - rankingConstants = new RankingConstants(null); + rankingConstants = new RankingConstants(null, Optional.empty()); largeRankExpressions = new LargeRankExpressions(null); - onnxModels = new OnnxModels(null); + onnxModels = new OnnxModels(null, Optional.empty()); } /** * Creates a rank profile * - * @param search the search definition this is a rank profile from + * @param schema the schema this is a rank profile from * @param attributeFields the attribute fields to create a ranking for */ - public RankProfileList(Search search, + public RankProfileList(Schema schema, RankingConstants rankingConstants, LargeRankExpressions largeRankExpressions, OnnxModels onnxModels, @@ -66,11 +67,11 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ ImportedMlModels importedModels, ModelContext.Properties deployProperties, ExecutorService executor) { - setName(search == null ? "default" : search.getName()); + setName(schema == null ? "default" : schema.getName()); this.rankingConstants = rankingConstants; this.largeRankExpressions = largeRankExpressions; this.onnxModels = onnxModels; // as ONNX models come from parsing rank expressions - deriveRankProfiles(rankProfileRegistry, queryProfiles, importedModels, search, attributeFields, deployProperties, executor); + deriveRankProfiles(rankProfileRegistry, queryProfiles, importedModels, schema, attributeFields, deployProperties, executor); } private boolean areDependenciesReady(RankProfile rank, RankProfileRegistry registry) { @@ -82,38 +83,38 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ private void deriveRankProfiles(RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfiles, ImportedMlModels importedModels, - Search search, + Schema schema, AttributeFields attributeFields, ModelContext.Properties deployProperties, ExecutorService executor) { - if (search != null) { // profiles belonging to a search have a default profile - RawRankProfile rawRank = new RawRankProfile(rankProfileRegistry.get(search, "default"), + if (schema != null) { // profiles belonging to a search have a default profile + RawRankProfile rawRank = new RawRankProfile(rankProfileRegistry.get(schema, "default"), largeRankExpressions, queryProfiles, importedModels, attributeFields, deployProperties); rankProfiles.put(rawRank.getName(), rawRank); } Map<String, RankProfile> remaining = new LinkedHashMap<>(); - rankProfileRegistry.rankProfilesOf(search).forEach(rank -> remaining.put(rank.getName(), rank)); + rankProfileRegistry.rankProfilesOf(schema).forEach(rank -> remaining.put(rank.getName(), rank)); remaining.remove("default"); while (!remaining.isEmpty()) { List<RankProfile> ready = new ArrayList<>(); remaining.forEach((name, rank) -> { if (areDependenciesReady(rank, rankProfileRegistry)) ready.add(rank); }); - processRankProfiles(ready, queryProfiles, importedModels, search, attributeFields, deployProperties, executor); + processRankProfiles(ready, queryProfiles, importedModels, schema, attributeFields, deployProperties, executor); ready.forEach(rank -> remaining.remove(rank.getName())); } } private void processRankProfiles(List<RankProfile> ready, QueryProfileRegistry queryProfiles, ImportedMlModels importedModels, - Search search, + Schema schema, AttributeFields attributeFields, ModelContext.Properties deployProperties, ExecutorService executor) { Map<String, Future<RawRankProfile>> futureRawRankProfiles = new LinkedHashMap<>(); for (RankProfile rank : ready) { - if (search == null) { + if (schema == null) { onnxModels.add(rank.onnxModels()); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/SearchOrderer.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/SearchOrderer.java index b55064cc49d..8703eb11433 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/SearchOrderer.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/SearchOrderer.java @@ -4,8 +4,8 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.document.DataTypeName; import com.yahoo.searchdefinition.DocumentReference; import com.yahoo.searchdefinition.DocumentReferences; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.SDDocumentType; -import com.yahoo.searchdefinition.Search; import java.util.*; @@ -23,7 +23,7 @@ import java.util.*; public class SearchOrderer { /** A map from DataTypeName to the Search defining them */ - private final Map<DataTypeName, Search> documentNameToSearch = new HashMap<>(); + private final Map<DataTypeName, Schema> documentNameToSearch = new HashMap<>(); /** * Reorders the given list of search definitions such that any supertype @@ -32,21 +32,21 @@ public class SearchOrderer { * * @return a new list containing the same search instances in the right order */ - public List<Search> order(List<Search> unordered) { + public List<Schema> order(List<Schema> unordered) { // Description above state that the original order should be preserved, except for the dependency constraint. // Yet we botch that guarantee by sorting the list... - unordered.sort(Comparator.comparing(Search::getName)); + unordered.sort(Comparator.comparing(Schema::getName)); // No, this is not a fast algorithm... indexOnDocumentName(unordered); - List<Search> ordered = new ArrayList<>(unordered.size()); - List<Search> moveOutwards = new ArrayList<>(); - for (Search search : unordered) { - if (allDependenciesAlreadyEmitted(ordered, search)) { - addOrdered(ordered, search, moveOutwards); + List<Schema> ordered = new ArrayList<>(unordered.size()); + List<Schema> moveOutwards = new ArrayList<>(); + for (Schema schema : unordered) { + if (allDependenciesAlreadyEmitted(ordered, schema)) { + addOrdered(ordered, schema, moveOutwards); } else { - moveOutwards.add(search); + moveOutwards.add(schema); } } @@ -58,9 +58,9 @@ public class SearchOrderer { return ordered; } - private void addOrdered(List<Search> ordered, Search search, List<Search> moveOutwards) { - ordered.add(search); - Search eligibleMove; + private void addOrdered(List<Schema> ordered, Schema schema, List<Schema> moveOutwards) { + ordered.add(schema); + Schema eligibleMove; do { eligibleMove = removeFirstEntryWithFullyEmittedDependencies(moveOutwards, ordered); if (eligibleMove != null) { @@ -70,8 +70,8 @@ public class SearchOrderer { } /** Removes and returns the first search from the move list which can now be added, or null if none */ - private Search removeFirstEntryWithFullyEmittedDependencies(List<Search> moveOutwards, List<Search> ordered) { - for (Search move : moveOutwards) { + private Schema removeFirstEntryWithFullyEmittedDependencies(List<Schema> moveOutwards, List<Schema> ordered) { + for (Schema move : moveOutwards) { if (allDependenciesAlreadyEmitted(ordered, move)) { moveOutwards.remove(move); return move; @@ -80,29 +80,29 @@ public class SearchOrderer { return null; } - private boolean allDependenciesAlreadyEmitted(List<Search> alreadyOrdered, Search search) { - if (search.getDocument() == null) { + private boolean allDependenciesAlreadyEmitted(List<Schema> alreadyOrdered, Schema schema) { + if (schema.getDocument() == null) { return true; } - SDDocumentType document = search.getDocument(); + SDDocumentType document = schema.getDocument(); return allInheritedDependenciesEmitted(alreadyOrdered, document) && allReferenceDependenciesEmitted(alreadyOrdered, document); } - private boolean allInheritedDependenciesEmitted(List<Search> alreadyOrdered, SDDocumentType document) { + private boolean allInheritedDependenciesEmitted(List<Schema> alreadyOrdered, SDDocumentType document) { for (SDDocumentType sdoc : document.getInheritedTypes() ) { DataTypeName inheritedName = sdoc.getDocumentName(); if ("document".equals(inheritedName.getName())) { continue; } - Search inheritedSearch = documentNameToSearch.get(inheritedName); - if (!alreadyOrdered.contains(inheritedSearch)) { + Schema inheritedSchema = documentNameToSearch.get(inheritedName); + if (!alreadyOrdered.contains(inheritedSchema)) { return false; } } return true; } - private static boolean allReferenceDependenciesEmitted(List<Search> alreadyOrdered, SDDocumentType document) { + private static boolean allReferenceDependenciesEmitted(List<Schema> alreadyOrdered, SDDocumentType document) { DocumentReferences documentReferences = document.getDocumentReferences() .orElseThrow(() -> new IllegalStateException("Missing document references. Should have been processed by now.")); return documentReferences.stream() @@ -111,11 +111,11 @@ public class SearchOrderer { .allMatch(alreadyOrdered::contains); } - private void indexOnDocumentName(List<Search> searches) { + private void indexOnDocumentName(List<Schema> schemas) { documentNameToSearch.clear(); - for (Search search : searches) { - if (search.getDocument() != null) { - documentNameToSearch.put(search.getDocument().getDocumentName(),search); + for (Schema schema : schemas) { + if (schema.getDocument() != null) { + documentNameToSearch.put(schema.getDocument().getDocumentName(), schema); } } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/Summaries.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/Summaries.java index a91bbeed9b2..5fdc51e8f5f 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/Summaries.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/Summaries.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.config.application.api.DeployLogger; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.vespa.documentmodel.DocumentSummary; import com.yahoo.vespa.config.search.SummaryConfig; import java.util.List; @@ -16,12 +16,12 @@ public class Summaries extends Derived implements SummaryConfig.Producer { private List<SummaryClass> summaries=new java.util.ArrayList<>(1); - public Summaries(Search search, DeployLogger deployLogger) { + public Summaries(Schema schema, DeployLogger deployLogger) { // Make sure the default is first - summaries.add(new SummaryClass(search,search.getSummary("default"), deployLogger)); - for (DocumentSummary summary : search.getSummaries().values()) { + summaries.add(new SummaryClass(schema, schema.getSummary("default"), deployLogger)); + for (DocumentSummary summary : schema.getSummaries().values()) { if (!summary.getName().equals("default")) - summaries.add(new SummaryClass(search,summary, deployLogger)); + summaries.add(new SummaryClass(schema, summary, deployLogger)); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/SummaryClass.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/SummaryClass.java index 2b40822b23b..5f88ddba5f5 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/SummaryClass.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/SummaryClass.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.document.DataType; import com.yahoo.prelude.fastsearch.DocsumDefinitionSet; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.vespa.config.search.SummaryConfig; import com.yahoo.vespa.documentmodel.DocumentSummary; import com.yahoo.vespa.documentmodel.SummaryField; @@ -42,12 +42,12 @@ public class SummaryClass extends Derived { * * @param deployLogger a {@link DeployLogger} */ - public SummaryClass(Search search, DocumentSummary summary, DeployLogger deployLogger) { + public SummaryClass(Schema schema, DocumentSummary summary, DeployLogger deployLogger) { this.deployLogger = deployLogger; - this.rawAsBase64 = search.isRawAsBase64(); + this.rawAsBase64 = schema.isRawAsBase64(); this.omitSummaryFeatures = summary.omitSummaryFeatures(); deriveName(summary); - deriveFields(search,summary); + deriveFields(schema, summary); deriveImplicitFields(summary); } @@ -62,9 +62,9 @@ public class SummaryClass extends Derived { } } - private void deriveFields(Search search, DocumentSummary summary) { + private void deriveFields(Schema schema, DocumentSummary summary) { for (SummaryField summaryField : summary.getSummaryFields()) { - if (!accessingDiskSummary && search.isAccessingDiskSummary(summaryField)) { + if (!accessingDiskSummary && schema.isAccessingDiskSummary(summaryField)) { accessingDiskSummary = true; } addField(summaryField.getName(), summaryField.getDataType(), summaryField.getTransform()); diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/SummaryMap.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/SummaryMap.java index c53dba0bab0..cf182a1afbc 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/SummaryMap.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/SummaryMap.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.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.vespa.config.search.SummarymapConfig; import com.yahoo.vespa.documentmodel.DocumentSummary; @@ -23,19 +23,19 @@ public class SummaryMap extends Derived implements SummarymapConfig.Producer { private Map<String,FieldResultTransform> resultTransforms = new java.util.LinkedHashMap<>(); /** Creates a summary map from a search definition */ - SummaryMap(Search search) { - derive(search); + SummaryMap(Schema schema) { + derive(schema); } - protected void derive(Search search) { - for (DocumentSummary documentSummary : search.getSummaries().values()) { + protected void derive(Schema schema) { + for (DocumentSummary documentSummary : schema.getSummaries().values()) { derive(documentSummary); } - super.derive(search); + super.derive(schema); } @Override - protected void derive(ImmutableSDField field, Search search) { + protected void derive(ImmutableSDField field, Schema schema) { } private void derive(DocumentSummary documentSummary) { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/VsmFields.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/VsmFields.java index a301f3983a6..2fd90d6c87e 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/VsmFields.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/VsmFields.java @@ -12,7 +12,7 @@ import com.yahoo.document.datatypes.Raw; import com.yahoo.document.datatypes.StringFieldValue; import com.yahoo.document.datatypes.TensorFieldValue; import com.yahoo.searchdefinition.FieldSets; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.FieldSet; import com.yahoo.searchdefinition.document.Matching; import com.yahoo.searchdefinition.document.SDDocumentType; @@ -30,20 +30,20 @@ public class VsmFields extends Derived implements VsmfieldsConfig.Producer { private final Map<String, StreamingField> fields=new LinkedHashMap<>(); private final Map<String, StreamingDocumentType> doctypes=new LinkedHashMap<>(); - public VsmFields(Search search) { - addSearchdefinition(search); + public VsmFields(Schema schema) { + addSearchdefinition(schema); } - private void addSearchdefinition(Search search) { - derive(search); + private void addSearchdefinition(Schema schema) { + derive(schema); } @Override - protected void derive(SDDocumentType document,Search search) { - super.derive(document, search); + protected void derive(SDDocumentType document, Schema schema) { + super.derive(document, schema); StreamingDocumentType docType=getDocumentType(document.getName()); if (docType == null) { - docType = new StreamingDocumentType(document.getName(), search.fieldSets()); + docType = new StreamingDocumentType(document.getName(), schema.fieldSets()); doctypes.put(document.getName(), docType); } for (Object o : document.fieldSet()) { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/VsmSummary.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/VsmSummary.java index 44ba9df8226..a2c90bc92f5 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/VsmSummary.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/VsmSummary.java @@ -2,9 +2,9 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.document.PositionDataType; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; -import com.yahoo.searchdefinition.Search; import com.yahoo.vespa.documentmodel.DocumentSummary; import com.yahoo.vespa.documentmodel.SummaryField; import com.yahoo.vespa.config.search.vsm.VsmsummaryConfig; @@ -20,23 +20,23 @@ public class VsmSummary extends Derived implements VsmsummaryConfig.Producer { private Map<SummaryField, List<String>> summaryMap = new java.util.LinkedHashMap<>(1); - public VsmSummary(Search search) { - derive(search); + public VsmSummary(Schema schema) { + derive(schema); } @Override - protected void derive(Search search) { + protected void derive(Schema schema) { // Use the default class, as it is the superset - derive(search, search.getSummary("default")); + derive(schema, schema.getSummary("default")); } - private void derive(Search search, DocumentSummary documentSummary) { + private void derive(Schema schema, DocumentSummary documentSummary) { if (documentSummary==null) return; for (SummaryField summaryField : documentSummary.getSummaryFields()) { List<String> from = toStringList(summaryField.sourceIterator()); - if (doMapField(search, summaryField)) { - SDField sdField = search.getConcreteField(summaryField.getName()); + if (doMapField(schema, summaryField)) { + SDField sdField = schema.getConcreteField(summaryField.getName()); if (sdField != null && PositionDataType.INSTANCE.equals(sdField.getDataType())) { summaryMap.put(summaryField, Collections.singletonList(summaryField.getName())); } else { @@ -52,9 +52,9 @@ public class VsmSummary extends Derived implements VsmsummaryConfig.Producer { * Don't map if not struct either. * @param summaryField a {@link SummaryField} */ - private boolean doMapField(Search search, SummaryField summaryField) { - SDField sdField = search.getConcreteField(summaryField.getName()); - SDDocumentType document = search.getDocument(); + private boolean doMapField(Schema schema, SummaryField summaryField) { + SDField sdField = schema.getConcreteField(summaryField.getName()); + SDDocumentType document = schema.getDocument(); if (sdField==null || ((document != null) && (document.getField(summaryField.getName()) == sdField))) { return true; } @@ -66,7 +66,7 @@ public class VsmSummary extends Derived implements VsmsummaryConfig.Producer { } if (summaryField.getSourceCount()==sdField.getStructFields().size()) { for (SummaryField.Source source : summaryField.getSources()) { - if (!sdField.getStructFields().contains(new SDField(search.getDocument(), source.getName(), sdField.getDataType()))) { // equals() uses just name + if (!sdField.getStructFields().contains(new SDField(schema.getDocument(), source.getName(), sdField.getDataType()))) { // equals() uses just name return true; } if (sdField.getStructField(source.getName())!=null && !sdField.getStructField(source.getName()).doesSummarying()) { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/validation/IndexStructureValidator.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/validation/IndexStructureValidator.java index c41437f2531..76f52bce2a9 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/validation/IndexStructureValidator.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/validation/IndexStructureValidator.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.derived.validation; import com.yahoo.searchdefinition.document.SDDocumentType; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.derived.DerivedConfiguration; import com.yahoo.searchdefinition.derived.IndexingScript; import com.yahoo.vespa.indexinglanguage.ExpressionVisitor; @@ -14,14 +14,14 @@ import com.yahoo.vespa.indexinglanguage.expressions.OutputExpression; */ public class IndexStructureValidator extends Validator { - public IndexStructureValidator(DerivedConfiguration config, Search search) { - super(config, search); + public IndexStructureValidator(DerivedConfiguration config, Schema schema) { + super(config, schema); } public void validate() { IndexingScript script = config.getIndexingScript(); for (Expression exp : script.expressions()) { - new OutputVisitor(search.getDocument(), exp).visit(exp); + new OutputVisitor(schema.getDocument(), exp).visit(exp); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/validation/Validation.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/validation/Validation.java index a32fe67312f..fd75fbb2f48 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/validation/Validation.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/validation/Validation.java @@ -1,12 +1,12 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition.derived.validation; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.derived.DerivedConfiguration; public class Validation { - public static void validate(DerivedConfiguration config, Search search) { - new IndexStructureValidator(config, search).validate(); + public static void validate(DerivedConfiguration config, Schema schema) { + new IndexStructureValidator(config, schema).validate(); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/validation/Validator.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/validation/Validator.java index 170639f5deb..7d3e5b8e9ed 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/validation/Validator.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/validation/Validator.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.validation; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.derived.DerivedConfiguration; /** @@ -10,11 +10,11 @@ import com.yahoo.searchdefinition.derived.DerivedConfiguration; public abstract class Validator { protected DerivedConfiguration config; - protected Search search; + protected Schema schema; - protected Validator(DerivedConfiguration config, Search search) { + protected Validator(DerivedConfiguration config, Schema schema) { this.config = config; - this.search = search; + this.schema = schema; } public abstract void validate(); diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/document/ImmutableImportedSDField.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/ImmutableImportedSDField.java index 925b67014e5..71814c31087 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/document/ImmutableImportedSDField.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/ImmutableImportedSDField.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.document; import com.yahoo.document.DataType; import com.yahoo.document.Field; import com.yahoo.searchdefinition.Index; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.vespa.documentmodel.SummaryField; import com.yahoo.vespa.indexinglanguage.expressions.Expression; import com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression; @@ -151,7 +151,7 @@ public class ImmutableImportedSDField implements ImmutableSDField { } @Override - public Stemming getStemming(Search search) { + public Stemming getStemming(Schema schema) { throw createUnsupportedException("stemming"); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/document/ImmutableSDField.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/ImmutableSDField.java index d54f76614c0..6d1dee67641 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/document/ImmutableSDField.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/ImmutableSDField.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.document; import com.yahoo.document.DataType; import com.yahoo.document.Field; import com.yahoo.searchdefinition.Index; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.vespa.documentmodel.SummaryField; import com.yahoo.vespa.indexinglanguage.expressions.Expression; import com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression; @@ -69,7 +69,7 @@ public interface ImmutableSDField { Stemming getStemming(); - Stemming getStemming(Search search); + Stemming getStemming(Schema schema); Ranking getRanking(); diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/document/ImportedFields.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/ImportedFields.java index 92a55d40048..18bd3f43445 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/document/ImportedFields.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/ImportedFields.java @@ -1,6 +1,8 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition.document; +import com.yahoo.searchdefinition.Schema; + import java.util.Collections; import java.util.Map; diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/document/SDDocumentType.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/SDDocumentType.java index 5d50abec8bb..6424db1c2dd 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/document/SDDocumentType.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/SDDocumentType.java @@ -14,7 +14,7 @@ import com.yahoo.documentmodel.NewDocumentType; import com.yahoo.documentmodel.VespaDocumentType; import com.yahoo.searchdefinition.DocumentReferences; import com.yahoo.searchdefinition.FieldSets; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import java.io.Serializable; import java.util.ArrayList; @@ -66,17 +66,15 @@ public class SDDocumentType implements Cloneable, Serializable { /** * For adding structs defined in document scope * - * @param dt The struct to add. + * @param dt the struct to add * @return self, for chaining */ public SDDocumentType addType(SDDocumentType dt) { NewDocumentType.Name name = new NewDocumentType.Name(dt.getName()); - if (getType(name) != null) { - throw new IllegalArgumentException("Data type '" + name.toString() + "' has already been used."); - } - if (name.getName() == docType.getName()) { - throw new IllegalArgumentException("Data type '" + name.toString() + "' can not have same name as its defining document."); - } + if (getType(name) != null) + throw new IllegalArgumentException("Data type '" + name + "' has already been used."); + if (name.getName() == docType.getName()) + throw new IllegalArgumentException("Data type '" + name + "' can not have same name as its defining document."); ownedTypes.put(name, dt); return this; } @@ -113,12 +111,11 @@ public class SDDocumentType implements Cloneable, Serializable { return this; } - /** - * Access to all owned datatypes. - * @return all types - */ + /** Returns all owned datatypes. */ public Collection<SDDocumentType> getTypes() { return ownedTypes.values(); } - public Collection<AnnotationType> getAnnotations() { return annotationTypes.getTypes().values(); } + + // TODO: Include inherited + public Map<String, AnnotationType> getAnnotations() { return annotationTypes.getTypes(); } public AnnotationType findAnnotation(String name) { return annotationTypes.getType(name); } public Collection<SDDocumentType> getAllTypes() { @@ -149,13 +146,13 @@ public class SDDocumentType implements Cloneable, Serializable { * The document type id will be generated as a hash from the document type name. * * @param name The name of the new document type - * @param search check for type ID collisions in this search definition + * @param schema check for type ID collisions in this search definition */ @SuppressWarnings("deprecation") - public SDDocumentType(String name, Search search) { + public SDDocumentType(String name, Schema schema) { docType = new DocumentType(name); docType.contentStruct().setCompressionConfig(new CompressionConfig()); - validateId(search); + validateId(schema); inherit(VESPA_DOCUMENT); } @@ -196,10 +193,12 @@ public class SDDocumentType implements Cloneable, Serializable { public Collection<SDDocumentType> getInheritedTypes() { return inheritedTypes.values(); } - protected void validateId(Search search) { - if (search == null) return; - if (search.getDocument(getName()) == null) return; - SDDocumentType doc = search.getDocument(); + public Map<DataTypeName, SDDocumentType> inheritedTypes() { return inheritedTypes; } + + protected void validateId(Schema schema) { + if (schema == null) return; + if (schema.getDocument(getName()) == null) return; + SDDocumentType doc = schema.getDocument(); throw new IllegalArgumentException("Failed creating document type '" + getName() + "', " + "document type '" + doc.getName() + "' already uses ID '" + doc.getName() + "'"); } @@ -249,7 +248,7 @@ public class SDDocumentType implements Cloneable, Serializable { for (Field pField : parent.fieldSet()) { if (pField.getName().equals(field.getName())) { if (!pField.getDataType().equals(field.getDataType())) { - throw new IllegalArgumentException("For search '" + getName() + "', field '" + field.getName() + + throw new IllegalArgumentException("For " + this + ", field '" + field.getName() + "': Datatype can not be different from that of same field " + "in the supertype '" + parent.getName() + "'"); } @@ -300,7 +299,7 @@ public class SDDocumentType implements Cloneable, Serializable { @Override public String toString() { - return "SD document type '" + docType.getName() + "'"; + return "document type '" + docType.getName() + "'"; } private static SDDocumentType createSDDocumentType(StructDataType structType) { @@ -312,7 +311,7 @@ public class SDDocumentType implements Cloneable, Serializable { return docType; } - /** The field sets defined for this type and its {@link Search} */ + /** The field sets defined for this type and its {@link Schema} */ public FieldSets getFieldSets() { return fieldSets; } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java index a66820a9bfe..566342403d4 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java @@ -12,7 +12,7 @@ import com.yahoo.language.Linguistics; import com.yahoo.language.process.Embedder; import com.yahoo.language.simple.SimpleLinguistics; import com.yahoo.searchdefinition.Index; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.fieldoperation.FieldOperation; import com.yahoo.searchdefinition.fieldoperation.FieldOperationContainer; import com.yahoo.tensor.TensorType; @@ -672,11 +672,11 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer, * Whether this field should be stemmed in this search definition */ @Override - public Stemming getStemming(Search search) { + public Stemming getStemming(Schema schema) { if (stemming != null) return stemming; else - return search.getStemming(); + return schema.getStemming(); } @Override diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/document/TemporaryImportedFields.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/TemporaryImportedFields.java index 5733779ccc7..96f2f2f1d24 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/document/TemporaryImportedFields.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/TemporaryImportedFields.java @@ -1,7 +1,10 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition.document; +import com.yahoo.searchdefinition.Schema; + import java.util.Collections; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; @@ -14,15 +17,32 @@ import java.util.Map; */ public class TemporaryImportedFields { + private final Schema owner; private final Map<String, TemporaryImportedField> fields = new LinkedHashMap<>(); + public TemporaryImportedFields(Schema owner) { + this.owner = owner; + } + public void add(TemporaryImportedField importedField) { fields.put(importedField.fieldName(), importedField); } - public boolean hasField(String fieldName) { return fields.get(fieldName) != null; } + public boolean hasField(String fieldName) { + boolean has = fields.get(fieldName) != null; + if (has) return true; + if (owner.inherited().isEmpty()) return false; + if (owner.inherited().get().temporaryImportedFields().isEmpty()) return false; + return owner.inherited().get().temporaryImportedFields().get().hasField(fieldName); + } public Map<String, TemporaryImportedField> fields() { - return Collections.unmodifiableMap(fields); + if (owner.inherited().isEmpty()) return Collections.unmodifiableMap(fields); + if (owner.inherited().get().temporaryImportedFields().isEmpty()) return Collections.unmodifiableMap(fields); + + var allFields = new HashMap<>(owner.inherited().get().temporaryImportedFields().get().fields()); + allFields.putAll(fields); + return allFields; } + } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/OnnxModelTransformer.java b/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/OnnxModelTransformer.java index abfb0c43d84..faf3c8085d8 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/OnnxModelTransformer.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/expressiontransforms/OnnxModelTransformer.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.expressiontransforms; import com.yahoo.path.Path; -import com.yahoo.searchdefinition.ImmutableSearch; +import com.yahoo.searchdefinition.ImmutableSchema; import com.yahoo.searchdefinition.OnnxModel; import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchlib.rankingexpression.Reference; @@ -54,7 +54,7 @@ public class OnnxModelTransformer extends ExpressionTransformer<RankProfileTrans } public static ExpressionNode transformFeature(ReferenceNode feature, RankProfile rankProfile) { - ImmutableSearch search = rankProfile.getSearch(); + ImmutableSchema search = rankProfile.getSearch(); final String featureName = feature.getName(); if ( ! featureName.equals("onnxModel") && ! featureName.equals("onnx")) return feature; diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/AddAttributeTransformToSummaryOfImportedFields.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/AddAttributeTransformToSummaryOfImportedFields.java index 213928b3edb..ac4d51221ef 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/AddAttributeTransformToSummaryOfImportedFields.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/AddAttributeTransformToSummaryOfImportedFields.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.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.ImmutableImportedComplexSDField; import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.vespa.documentmodel.SummaryField; @@ -20,21 +20,21 @@ import java.util.stream.Stream; */ public class AddAttributeTransformToSummaryOfImportedFields extends Processor { - public AddAttributeTransformToSummaryOfImportedFields(Search search, + public AddAttributeTransformToSummaryOfImportedFields(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - search.allImportedFields() - .forEach(field -> setTransform(field)); + schema.allImportedFields() + .forEach(field -> setTransform(field)); } private Stream<SummaryField> getSummaryFieldsForImportedField(ImmutableSDField importedField) { - return search.getSummaryFields(importedField).values().stream(); + return schema.getSummaryFields(importedField).values().stream(); } private void setTransform(ImmutableSDField field) { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/AddExtraFieldsToDocument.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/AddExtraFieldsToDocument.java index 152399337fd..9ade1786e37 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/AddExtraFieldsToDocument.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/AddExtraFieldsToDocument.java @@ -6,7 +6,7 @@ import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.document.DataType; import com.yahoo.document.Field; import com.yahoo.document.PositionDataType; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.searchdefinition.document.SDDocumentType; @@ -15,14 +15,15 @@ import com.yahoo.vespa.documentmodel.SummaryField; import com.yahoo.vespa.model.container.search.QueryProfiles; /** - * This processor creates a {@link com.yahoo.searchdefinition.document.SDDocumentType} for each {@link Search} object which holds all the data that search + * This processor creates a {@link com.yahoo.searchdefinition.document.SDDocumentType} for each {@link Schema} + * object which holds all the data that search * associates with a document described in a search definition file. This includes all extra fields, summary fields and * implicit fields. All non-indexed and non-summary fields are discarded. */ public class AddExtraFieldsToDocument extends Processor { - AddExtraFieldsToDocument(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + AddExtraFieldsToDocument(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } //TODO This is a tempoarry hack to avoid producing illegal code for fields not wanted anyway. @@ -32,44 +33,43 @@ public class AddExtraFieldsToDocument extends Processor { @Override public void process(boolean validate, boolean documentsOnly) { - SDDocumentType document = search.getDocument(); + SDDocumentType document = schema.getDocument(); if (document != null) { - for (Field field : search.extraFieldList()) { - addSdField(search, document, (SDField)field, validate); + for (SDField field : schema.extraFieldList()) { + addSdField(schema, document, field, validate); } //TODO Vespa 8 or sooner we should avoid the dirty addition of fields from dirty 'default' summary to document at all - for (SummaryField field : search.getSummary("default").getSummaryFields()) { + for (SummaryField field : schema.getSummary("default").getSummaryFields()) { if (dirtyLegalFieldNameCheck(field.getName())) { - addSummaryField(search, document, field, validate); + addSummaryField(schema, document, field, validate); } } } } - private void addSdField(Search search, SDDocumentType document, SDField field, boolean validate) { + private void addSdField(Schema schema, SDDocumentType document, SDField field, boolean validate) { if (! field.hasIndex() && field.getAttributes().isEmpty()) { return; } for (Attribute atr : field.getAttributes().values()) { - // TODO Vespa 8 or before: Check if this sould be removed or changed to _zcurve. + // TODO Vespa 8 or before: Check if this should be removed or changed to _zcurve. if (atr.getName().equals(field.getName() + "_position")) { DataType type = PositionDataType.INSTANCE; if (atr.getCollectionType().equals(Attribute.CollectionType.ARRAY)) { type = DataType.getArray(type); } - addField(search, document, new SDField(document, atr.getName(), type), validate); + addField(schema, document, new SDField(document, atr.getName(), type), validate); } else if (!atr.getName().equals(field.getName())) { - addField(search, document, new SDField(document, atr.getName(), atr.getDataType()), validate); + addField(schema, document, new SDField(document, atr.getName(), atr.getDataType()), validate); } } - addField(search, document, field, validate); + addField(schema, document, field, validate); } - @SuppressWarnings("deprecation") - private void addSummaryField(Search search, SDDocumentType document, SummaryField field, boolean validate) { + private void addSummaryField(Schema schema, SDDocumentType document, SummaryField field, boolean validate) { Field docField = document.getField(field.getName()); if (docField == null) { - ImmutableSDField existingField = search.getField(field.getName()); + ImmutableSDField existingField = schema.getField(field.getName()); if (existingField == null) { SDField newField = new SDField(document, field.getName(), field.getDataType(), true); newField.setIsExtraField(true); @@ -79,14 +79,14 @@ public class AddExtraFieldsToDocument extends Processor { } } else if (!docField.getDataType().equals(field.getDataType())) { if (validate) - throw newProcessException(search, field, "Summary field has conflicting type."); + throw newProcessException(schema, field, "Summary field has conflicting type."); } } - private void addField(Search search, SDDocumentType document, Field field, boolean validate) { - if (document.getField(field.getName()) != null) { + private void addField(Schema schema, SDDocumentType document, Field field, boolean validate) { + if (document.getField(field.getName()) != null && !(document.getField(field.getName()) == field)) { if (validate) - throw newProcessException(search, field, "Field shadows another."); + throw newProcessException(schema, field, "Field shadows another."); } document.addField(field); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/AdjustPositionSummaryFields.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/AdjustPositionSummaryFields.java index fd103f3901c..176fcf2130f 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/AdjustPositionSummaryFields.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/AdjustPositionSummaryFields.java @@ -6,7 +6,7 @@ import com.yahoo.document.ArrayDataType; import com.yahoo.document.DataType; import com.yahoo.document.PositionDataType; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.vespa.documentmodel.DocumentSummary; @@ -21,13 +21,13 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class AdjustPositionSummaryFields extends Processor { - public AdjustPositionSummaryFields(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public AdjustPositionSummaryFields(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - for (DocumentSummary summary : search.getSummaries().values()) { + for (DocumentSummary summary : schema.getSummaries().values()) { scanSummary(summary); } } @@ -37,7 +37,7 @@ public class AdjustPositionSummaryFields extends Processor { if (isPositionDataType(summaryField.getDataType())) { String originalSource = summaryField.getSingleSource(); if (originalSource.indexOf('.') == -1) { // Eliminate summary fields with pos.x or pos.y as source - ImmutableSDField sourceField = search.getField(originalSource); + ImmutableSDField sourceField = schema.getField(originalSource); if (sourceField != null) { String zCurve = null; if (sourceField.getDataType().equals(summaryField.getDataType())) { @@ -77,7 +77,7 @@ public class AdjustPositionSummaryFields extends Processor { } private void ensureSummaryField(DocumentSummary summary, String fieldName, DataType dataType, Source source, SummaryTransform transform) { - SummaryField oldField = search.getSummaryField(fieldName); + SummaryField oldField = schema.getSummaryField(fieldName); if (oldField == null) { SummaryField newField = new SummaryField(fieldName, dataType, transform); newField.addSource(source); @@ -97,9 +97,9 @@ public class AdjustPositionSummaryFields extends Processor { } private boolean hasPositionAttribute(String name) { - Attribute attribute = search.getAttribute(name); + Attribute attribute = schema.getAttribute(name); if (attribute == null) { - ImmutableSDField field = search.getField(name); + ImmutableSDField field = schema.getField(name); if (field != null && field.isImportedField()) { attribute = field.getAttribute(); } @@ -121,7 +121,7 @@ public class AdjustPositionSummaryFields extends Processor { } private void fail(SummaryField summaryField, String msg) { - throw newProcessException(search.getName(), summaryField.getName(), msg); + throw newProcessException(schema.getName(), summaryField.getName(), msg); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/AttributeProperties.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/AttributeProperties.java index e7cc562b42d..42e14a2c1ee 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/AttributeProperties.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/AttributeProperties.java @@ -3,10 +3,10 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.searchdefinition.document.SDField; -import com.yahoo.searchdefinition.Search; import com.yahoo.vespa.model.container.search.QueryProfiles; /** @@ -16,13 +16,13 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class AttributeProperties extends Processor { - public AttributeProperties(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public AttributeProperties(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - for (ImmutableSDField field : search.allConcreteFields()) { + for (ImmutableSDField field : schema.allConcreteFields()) { String fieldName = field.getName(); // For each attribute, check if the attribute has been created @@ -33,7 +33,7 @@ public class AttributeProperties extends Processor { } // Check other fields or statements that may have created this attribute. boolean created = false; - for (SDField f : search.allConcreteFields()) { + for (SDField f : schema.allConcreteFields()) { // Checking against the field we are looking at if (!f.getName().equals(fieldName)) { if (attributeCreated(f, attribute.getName())) { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/AttributesImplicitWord.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/AttributesImplicitWord.java index 27e9d5a070f..d3fa3282f4f 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/AttributesImplicitWord.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/AttributesImplicitWord.java @@ -4,10 +4,10 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.document.DataType; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.searchdefinition.document.Matching; import com.yahoo.document.NumericDataType; -import com.yahoo.searchdefinition.Search; import com.yahoo.vespa.model.container.search.QueryProfiles; /** @@ -18,13 +18,13 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class AttributesImplicitWord extends Processor { - public AttributesImplicitWord(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public AttributesImplicitWord(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - for (ImmutableSDField field : search.allConcreteFields()) { + for (ImmutableSDField field : schema.allConcreteFields()) { processFieldRecursive(field); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/Bolding.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/Bolding.java index 8c62cdfaec6..575a037be91 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/Bolding.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/Bolding.java @@ -5,7 +5,7 @@ import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.document.DataType; import com.yahoo.searchdefinition.document.ImmutableSDField; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.vespa.documentmodel.SummaryField; import com.yahoo.vespa.model.container.search.QueryProfiles; @@ -17,14 +17,14 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class Bolding extends Processor { - public Bolding(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public Bolding(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { if ( ! validate) return; - for (ImmutableSDField field : search.allConcreteFields()) { + for (ImmutableSDField field : schema.allConcreteFields()) { for (SummaryField summary : field.getSummaryFields().values()) { if (summary.getTransform().isBolded() && !((summary.getDataType() == DataType.STRING) || (summary.getDataType() == DataType.URI))) diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/BoolAttributeValidator.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/BoolAttributeValidator.java index f4bf4432aa0..6676e20c341 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/BoolAttributeValidator.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/BoolAttributeValidator.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.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.vespa.model.container.search.QueryProfiles; @@ -16,20 +16,20 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class BoolAttributeValidator extends Processor { - public BoolAttributeValidator(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public BoolAttributeValidator(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - for (var field : search.allConcreteFields()) { + for (var field : schema.allConcreteFields()) { var attribute = field.getAttribute(); if (attribute == null) { continue; } if (attribute.getType().equals(Attribute.Type.BOOL) && !attribute.getCollectionType().equals(Attribute.CollectionType.SINGLE)) { - fail(search, field, "Only single value bool attribute fields are supported"); + fail(schema, field, "Only single value bool attribute fields are supported"); } } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/BuiltInFieldSets.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/BuiltInFieldSets.java index fc23042649b..ce93c1a5c3f 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/BuiltInFieldSets.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/BuiltInFieldSets.java @@ -5,7 +5,7 @@ import com.yahoo.config.application.api.DeployLogger; import com.yahoo.document.DocumentType; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.document.Field; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.vespa.model.container.search.QueryProfiles; @@ -19,8 +19,8 @@ public class BuiltInFieldSets extends Processor { public static final String SEARCH_FIELDSET_NAME = "[search]"; // Public due to oddities in position handling. public static final String INTERNAL_FIELDSET_NAME = "[internal]"; // This one populated from misc places - public BuiltInFieldSets(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public BuiltInFieldSets(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override @@ -29,21 +29,21 @@ public class BuiltInFieldSets extends Processor { addSearchFieldSet(); // "Hook" the field sets on search onto the document types, since we will include them // on the document configs - search.getDocument().setFieldSets(search.fieldSets()); + schema.getDocument().setFieldSets(schema.fieldSets()); } private void addSearchFieldSet() { - for (SDField searchField : search.extraFieldList()) { - search.fieldSets().addBuiltInFieldSetItem(SEARCH_FIELDSET_NAME, searchField.getName()); + for (SDField searchField : schema.extraFieldList()) { + schema.fieldSets().addBuiltInFieldSetItem(SEARCH_FIELDSET_NAME, searchField.getName()); } } private void addDocumentFieldSet() { - for (Field docField : search.getDocument().fieldSet()) { + for (Field docField : schema.getDocument().fieldSet()) { if (docField instanceof SDField && ((SDField) docField).isExtraField()) { continue; // skip } - search.fieldSets().addBuiltInFieldSetItem(DocumentType.DOCUMENT, docField.getName()); + schema.fieldSets().addBuiltInFieldSetItem(DocumentType.DOCUMENT, docField.getName()); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/CreatePositionZCurve.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/CreatePositionZCurve.java index 7b0ea68db5a..699abb1e792 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/CreatePositionZCurve.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/CreatePositionZCurve.java @@ -6,7 +6,7 @@ import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.document.ArrayDataType; import com.yahoo.document.DataType; import com.yahoo.document.PositionDataType; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.vespa.documentmodel.SummaryField; @@ -33,18 +33,18 @@ import java.util.logging.Level; */ public class CreatePositionZCurve extends Processor { - public CreatePositionZCurve(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public CreatePositionZCurve(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { DataType fieldType = field.getDataType(); if ( ! isSupportedPositionType(fieldType)) continue; if (validate && field.doesIndexing()) { - fail(search, field, "Indexing of data type '" + fieldType.getName() + "' is not supported, " + + fail(schema, field, "Indexing of data type '" + fieldType.getName() + "' is not supported, " + "replace 'index' statement with 'attribute'."); } @@ -57,8 +57,8 @@ public class CreatePositionZCurve extends Processor { String zName = PositionDataType.getZCurveFieldName(fieldName); SDField zCurveField = createZCurveField(field, zName, validate); - search.addExtraField(zCurveField); - search.fieldSets().addBuiltInFieldSetItem(BuiltInFieldSets.INTERNAL_FIELDSET_NAME, zCurveField.getName()); + schema.addExtraField(zCurveField); + schema.fieldSets().addBuiltInFieldSetItem(BuiltInFieldSets.INTERNAL_FIELDSET_NAME, zCurveField.getName()); // configure summary Collection<String> summaryTo = removeSummaryTo(field); @@ -88,8 +88,8 @@ public class CreatePositionZCurve extends Processor { } private SDField createZCurveField(SDField inputField, String fieldName, boolean validate) { - if (validate && search.getConcreteField(fieldName) != null || search.getAttribute(fieldName) != null) { - throw newProcessException(search, null, "Incompatible position attribute '" + fieldName + + if (validate && schema.getConcreteField(fieldName) != null || schema.getAttribute(fieldName) != null) { + throw newProcessException(schema, null, "Incompatible position attribute '" + fieldName + "' already created."); } boolean isArray = inputField.getDataType() instanceof ArrayDataType; @@ -109,7 +109,7 @@ public class CreatePositionZCurve extends Processor { private void ensureCompatibleSummary(SDField field, String sourceName, String summaryName, DataType summaryType, SummaryTransform summaryTransform, Collection<String> summaryTo, boolean validate) { - SummaryField summary = search.getSummaryField(summaryName); + SummaryField summary = schema.getSummaryField(summaryName); if (summary == null) { summary = new SummaryField(summaryName, summaryType, summaryTransform); summary.addDestination("default"); @@ -117,7 +117,7 @@ public class CreatePositionZCurve extends Processor { field.addSummaryField(summary); } else if (!summary.getDataType().equals(summaryType)) { if (validate) - fail(search, field, "Incompatible summary field '" + summaryName + "' type "+summary.getDataType()+" already created."); + fail(schema, field, "Incompatible summary field '" + summaryName + "' type " + summary.getDataType() + " already created."); } else if (summary.getTransform() == SummaryTransform.NONE) { summary.setTransform(summaryTransform); summary.addDestination("default"); diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/DictionaryProcessor.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/DictionaryProcessor.java index d8331746968..dc620e38e96 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/DictionaryProcessor.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/DictionaryProcessor.java @@ -5,11 +5,10 @@ import com.yahoo.config.application.api.DeployLogger; import com.yahoo.document.NumericDataType; import com.yahoo.document.PrimitiveDataType; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.document.Case; import com.yahoo.searchdefinition.document.Dictionary; -import com.yahoo.searchdefinition.document.Matching; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.vespa.model.container.search.QueryProfiles; @@ -20,12 +19,12 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; * @author baldersheim */ public class DictionaryProcessor extends Processor { - public DictionaryProcessor(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public DictionaryProcessor(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { Attribute attribute = field.getAttribute(); if (attribute == null) continue; attribute.setCase(field.getMatching().getCase()); @@ -35,20 +34,20 @@ public class DictionaryProcessor extends Processor { if (attribute.isFastSearch()) { attribute.setDictionary(dictionary); } else { - fail(search, field, "You must specify 'attribute:fast-search' to allow dictionary control"); + fail(schema, field, "You must specify 'attribute:fast-search' to allow dictionary control"); } } else if (attribute.getDataType().getPrimitiveType() == PrimitiveDataType.STRING) { attribute.setDictionary(dictionary); if (dictionary.getType() == Dictionary.Type.HASH) { if (dictionary.getMatch() != Case.CASED) { - fail(search, field, "hash dictionary require cased match"); + fail(schema, field, "hash dictionary require cased match"); } } if (! dictionary.getMatch().equals(attribute.getCase())) { - fail(search, field, "Dictionary casing '" + dictionary.getMatch() + "' does not match field match casing '" + attribute.getCase() + "'"); + fail(schema, field, "Dictionary casing '" + dictionary.getMatch() + "' does not match field match casing '" + attribute.getCase() + "'"); } } else { - fail(search, field, "You can only specify 'dictionary:' for numeric or string fields"); + fail(schema, field, "You can only specify 'dictionary:' for numeric or string fields"); } } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/DisallowComplexMapAndWsetKeyTypes.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/DisallowComplexMapAndWsetKeyTypes.java index 74bc476f96b..6ffe00458a8 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/DisallowComplexMapAndWsetKeyTypes.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/DisallowComplexMapAndWsetKeyTypes.java @@ -8,9 +8,9 @@ import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.document.DataType; import com.yahoo.document.MapDataType; import com.yahoo.document.PrimitiveDataType; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.document.WeightedSetDataType; -import com.yahoo.searchdefinition.Search; import com.yahoo.vespa.model.container.search.QueryProfiles; /** @@ -20,8 +20,8 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class DisallowComplexMapAndWsetKeyTypes extends Processor { - public DisallowComplexMapAndWsetKeyTypes(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public DisallowComplexMapAndWsetKeyTypes(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override @@ -30,7 +30,7 @@ public class DisallowComplexMapAndWsetKeyTypes extends Processor { // TODO also traverse struct types to search for bad map or wset types. // Do this after document manager is fixed, do not start using the static stuff on SDDocumentTypes any more. - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { checkFieldType(field, field.getDataType()); } } @@ -42,12 +42,12 @@ public class DisallowComplexMapAndWsetKeyTypes extends Processor { } else if (dataType instanceof WeightedSetDataType) { DataType nestedType = ((WeightedSetDataType) dataType).getNestedType(); if ( ! (nestedType instanceof PrimitiveDataType)) { - fail(search, field, "Weighted set must have a primitive key type."); + fail(schema, field, "Weighted set must have a primitive key type."); } } else if (dataType instanceof MapDataType) { DataType keyType = ((MapDataType) dataType).getKeyType(); if ( ! (keyType instanceof PrimitiveDataType)) { - fail(search, field, "Map key type must be a primitive type."); + fail(schema, field, "Map key type must be a primitive type."); } checkFieldType(field, ((MapDataType) dataType).getValueType()); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/DiversitySettingsValidator.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/DiversitySettingsValidator.java index 282ca6b3645..40de25dbc76 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/DiversitySettingsValidator.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/DiversitySettingsValidator.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.vespa.model.container.search.QueryProfiles; @@ -13,8 +13,8 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class DiversitySettingsValidator extends Processor { - public DiversitySettingsValidator(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public DiversitySettingsValidator(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override @@ -22,7 +22,7 @@ public class DiversitySettingsValidator extends Processor { if ( ! validate) return; if (documentsOnly) return; - for (RankProfile rankProfile : rankProfileRegistry.rankProfilesOf(search.getName())) { + for (RankProfile rankProfile : rankProfileRegistry.rankProfilesOf(schema.getName())) { if (rankProfile.getMatchPhaseSettings() != null && rankProfile.getMatchPhaseSettings().getDiversity() != null) { validate(rankProfile, rankProfile.getMatchPhaseSettings().getDiversity()); } @@ -30,8 +30,8 @@ public class DiversitySettingsValidator extends Processor { } private void validate(RankProfile rankProfile, RankProfile.DiversitySettings settings) { String attributeName = settings.getAttribute(); - new AttributeValidator(search.getName(), rankProfile.getName(), - search.getAttribute(attributeName), attributeName).validate(); + new AttributeValidator(schema.getName(), rankProfile.getName(), + schema.getAttribute(attributeName), attributeName).validate(); } private static class AttributeValidator extends MatchPhaseSettingsValidator.AttributeValidator { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ExactMatch.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ExactMatch.java index deb37adfa94..a516667c524 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ExactMatch.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ExactMatch.java @@ -5,7 +5,7 @@ import com.yahoo.config.application.api.DeployLogger; import com.yahoo.document.CollectionDataType; import com.yahoo.document.DataType; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Matching; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.document.Stemming; @@ -27,30 +27,30 @@ public class ExactMatch extends Processor { public static final String DEFAULT_EXACT_TERMINATOR = "@@"; - ExactMatch(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + ExactMatch(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - for (SDField field : search.allConcreteFields()) { - processField(field, search); + for (SDField field : schema.allConcreteFields()) { + processField(field, schema); } } - private void processField(SDField field, Search search) { + private void processField(SDField field, Schema schema) { Matching.Type matching = field.getMatching().getType(); if (matching.equals(Matching.Type.EXACT) || matching.equals(Matching.Type.WORD)) { - implementExactMatch(field, search); + implementExactMatch(field, schema); } else if (field.getMatching().getExactMatchTerminator() != null) { - warn(search, field, "exact-terminator requires 'exact' matching to have any effect."); + warn(schema, field, "exact-terminator requires 'exact' matching to have any effect."); } for (var structField : field.getStructFields()) { - processField(structField, search); + processField(structField, schema); } } - private void implementExactMatch(SDField field, Search search) { + private void implementExactMatch(SDField field, Schema schema) { field.setStemming(Stemming.NONE); field.getNormalizing().inferLowercase(); @@ -62,7 +62,7 @@ public class ExactMatch extends Processor { && ! field.getMatching().getExactMatchTerminator().equals("")) { exactTerminator = field.getMatching().getExactMatchTerminator(); } else { - info(search, field, + info(schema, field, "With 'exact' matching, an exact-terminator is needed," + " using default value '" + exactTerminator +"' as terminator"); } @@ -75,7 +75,7 @@ public class ExactMatch extends Processor { } ScriptExpression script = field.getIndexingScript(); if (new ExpressionSearcher<>(IndexExpression.class).containedIn(script)) { - field.setIndexingScript((ScriptExpression)new MyProvider(search).convert(field.getIndexingScript())); + field.setIndexingScript((ScriptExpression)new MyProvider(schema).convert(field.getIndexingScript())); } } @@ -85,8 +85,8 @@ public class ExactMatch extends Processor { private static class MyProvider extends TypedTransformProvider { - MyProvider(Search search) { - super(ExactExpression.class, search); + MyProvider(Schema schema) { + super(ExactExpression.class, schema); } @Override diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/FastAccessValidator.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/FastAccessValidator.java index a6b61e28bfc..60cc5c1cbb4 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/FastAccessValidator.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/FastAccessValidator.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.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.vespa.model.container.search.QueryProfiles; @@ -16,26 +16,23 @@ import java.util.stream.Collectors; */ public class FastAccessValidator extends Processor { - public FastAccessValidator(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public FastAccessValidator(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { if ( ! validate) return; - String invalidAttributes = search.allFields() - .flatMap(field -> field.getAttributes().values().stream()) - .filter(FastAccessValidator::isIncompatibleAttribute) - .map(Attribute::getName) - .collect(Collectors.joining(", ")); + String invalidAttributes = schema.allFields() + .flatMap(field -> field.getAttributes().values().stream()) + .filter(FastAccessValidator::isIncompatibleAttribute) + .map(Attribute::getName) + .collect(Collectors.joining(", ")); if ( ! invalidAttributes.isEmpty()) { throw new IllegalArgumentException( - String.format( - "For search '%s': The following attributes have a type that is incompatible with fast-access: %s. " + - "Predicate, tensor and reference attributes are incompatible with fast-access.", - search.getName(), - invalidAttributes)); + "For " + schema + ": The following attributes have a type that is incompatible with fast-access: " + + invalidAttributes + ". Predicate, tensor and reference attributes are incompatible with fast-access."); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/FieldSetSettings.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/FieldSetSettings.java index 291b84fa67b..1c50f78b539 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/FieldSetSettings.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/FieldSetSettings.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.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.FieldSet; import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.searchdefinition.document.Matching; @@ -22,42 +22,42 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; // (this requires adding normalizing and stemming settings to FieldSet). public class FieldSetSettings extends Processor { - public FieldSetSettings(Search search, + public FieldSetSettings(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - for (FieldSet fieldSet : search.fieldSets().userFieldSets().values()) { + for (FieldSet fieldSet : schema.fieldSets().userFieldSets().values()) { if (validate) - checkFieldNames(search, fieldSet); - checkMatching(search, fieldSet); - checkNormalization(search, fieldSet); - checkStemming(search, fieldSet); + checkFieldNames(schema, fieldSet); + checkMatching(schema, fieldSet); + checkNormalization(schema, fieldSet); + checkStemming(schema, fieldSet); } } - private void checkFieldNames(Search search, FieldSet fieldSet) { + private void checkFieldNames(Schema schema, FieldSet fieldSet) { for (String field : fieldSet.getFieldNames()) { - if (search.getField(field) == null) - throw new IllegalArgumentException("For search '" + search.getName() + - "': Field '"+ field + "' in " + fieldSet + " does not exist."); + if (schema.getField(field) == null) + throw new IllegalArgumentException("For " + schema + ": Field '" + field + "' in " + + fieldSet + " does not exist."); } } - private void checkMatching(Search search, FieldSet fieldSet) { + private void checkMatching(Schema schema, FieldSet fieldSet) { Matching matching = fieldSet.getMatching(); for (String fieldName : fieldSet.getFieldNames()) { - ImmutableSDField field = search.getField(fieldName); + ImmutableSDField field = schema.getField(fieldName); Matching fieldMatching = field.getMatching(); if (matching == null) { matching = fieldMatching; } else { if ( ! matching.equals(fieldMatching)) { - warn(search, field.asField(), + warn(schema, field.asField(), "The matching settings for the fields in " + fieldSet + " are inconsistent " + "(explicitly or because of field type). This may lead to recall and ranking issues."); return; @@ -67,16 +67,16 @@ public class FieldSetSettings extends Processor { fieldSet.setMatching(matching); // Assign the uniquely determined matching to the field set } - private void checkNormalization(Search search, FieldSet fieldSet) { + private void checkNormalization(Schema schema, FieldSet fieldSet) { NormalizeLevel.Level normalizing = null; for (String fieldName : fieldSet.getFieldNames()) { - ImmutableSDField field = search.getField(fieldName); + ImmutableSDField field = schema.getField(fieldName); NormalizeLevel.Level fieldNorm = field.getNormalizing().getLevel(); if (normalizing == null) { normalizing = fieldNorm; } else { if ( ! normalizing.equals(fieldNorm)) { - warn(search, field.asField(), + warn(schema, field.asField(), "The normalization settings for the fields in " + fieldSet + " are inconsistent " + "(explicitly or because of field type). This may lead to recall and ranking issues."); return; @@ -85,16 +85,16 @@ public class FieldSetSettings extends Processor { } } - private void checkStemming(Search search, FieldSet fieldSet) { + private void checkStemming(Schema schema, FieldSet fieldSet) { Stemming stemming = null; for (String fieldName : fieldSet.getFieldNames()) { - ImmutableSDField field = search.getField(fieldName); + ImmutableSDField field = schema.getField(fieldName); Stemming fieldStemming = field.getStemming(); if (stemming == null) { stemming = fieldStemming; } else { if ( ! stemming.equals(fieldStemming)) { - warn(search, field.asField(), + warn(schema, field.asField(), "The stemming settings for the fields in the fieldset '"+fieldSet.getName()+ "' are inconsistent (explicitly or because of field type). " + "This may lead to recall and ranking issues."); diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/FilterFieldNames.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/FilterFieldNames.java index 201aaf46470..d89f83c333f 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/FilterFieldNames.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/FilterFieldNames.java @@ -3,10 +3,10 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.RankType; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.RankProfile; -import com.yahoo.searchdefinition.Search; import com.yahoo.vespa.model.container.search.QueryProfiles; import java.util.Iterator; @@ -21,23 +21,23 @@ import java.util.logging.Level; */ public class FilterFieldNames extends Processor { - public FilterFieldNames(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public FilterFieldNames(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { if (documentsOnly) return; - for (SDField f : search.allConcreteFields()) { + for (SDField f : schema.allConcreteFields()) { if (f.getRanking().isFilter()) { filterField(f.getName()); } } - for (RankProfile profile : rankProfileRegistry.rankProfilesOf(search)) { + for (RankProfile profile : rankProfileRegistry.rankProfilesOf(schema)) { Set<String> filterFields = new LinkedHashSet<>(); - findFilterFields(search, profile, filterFields); + findFilterFields(schema, profile, filterFields); for (Iterator<String> itr = filterFields.iterator(); itr.hasNext(); ) { String fieldName = itr.next(); profile.filterFields().add(fieldName); @@ -47,18 +47,18 @@ public class FilterFieldNames extends Processor { } private void filterField(String f) { - for (RankProfile rp : rankProfileRegistry.rankProfilesOf(search)) { + for (RankProfile rp : rankProfileRegistry.rankProfilesOf(schema)) { rp.filterFields().add(f); } } - private void findFilterFields(Search search, RankProfile profile, Set<String> filterFields) { + private void findFilterFields(Schema schema, RankProfile profile, Set<String> filterFields) { for (Iterator<RankProfile.RankSetting> itr = profile.declaredRankSettingIterator(); itr.hasNext(); ) { RankProfile.RankSetting setting = itr.next(); if (setting.getType().equals(RankProfile.RankSetting.Type.PREFERBITVECTOR) && ((Boolean)setting.getValue())) { String fieldName = setting.getFieldName(); - if (search.getConcreteField(fieldName) != null) { + if (schema.getConcreteField(fieldName) != null) { if ( ! profile.filterFields().contains(fieldName)) { filterFields.add(fieldName); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ImplicitSummaries.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ImplicitSummaries.java index edf9f744150..6b09234c469 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ImplicitSummaries.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ImplicitSummaries.java @@ -5,10 +5,10 @@ import java.util.logging.Level; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.document.PositionDataType; import com.yahoo.searchdefinition.document.SDField; -import com.yahoo.searchdefinition.Search; import com.yahoo.vespa.documentmodel.DocumentSummary; import com.yahoo.vespa.documentmodel.SummaryField; import com.yahoo.vespa.documentmodel.SummaryTransform; @@ -23,24 +23,24 @@ import static com.yahoo.searchdefinition.document.ComplexAttributeFieldUtils.isC */ public class ImplicitSummaries extends Processor { - public ImplicitSummaries(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public ImplicitSummaries(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - DocumentSummary defaultSummary = search.getSummary("default"); + DocumentSummary defaultSummary = schema.getSummary("default"); if (defaultSummary == null) { - defaultSummary = new DocumentSummary("default", search); + defaultSummary = new DocumentSummary("default", schema); defaultSummary.setFromDisk(true); - search.addSummary(defaultSummary); + schema.addSummary(defaultSummary); } - for (SDField field : search.allConcreteFields()) { - collectSummaries(field, search, validate); + for (SDField field : schema.allConcreteFields()) { + collectSummaries(field, schema, validate); } - for (DocumentSummary documentSummary : search.getSummaries().values()) { + for (DocumentSummary documentSummary : schema.getSummaries().values()) { documentSummary.purgeImplicits(); } } @@ -49,7 +49,7 @@ public class ImplicitSummaries extends Processor { sdField.addSummaryFieldSources(summaryField); } - private void collectSummaries(SDField field ,Search search, boolean validate) { + private void collectSummaries(SDField field , Schema schema, boolean validate) { SummaryField addedSummaryField=null; // Implicit @@ -65,7 +65,7 @@ public class ImplicitSummaries extends Processor { } if (fieldSummaryField != null) { for (String dest : fieldSummaryField.getDestinations()) { - DocumentSummary summary = search.getSummary(dest); + DocumentSummary summary = schema.getSummary(dest); if (summary != null) { summary.add(fieldSummaryField); } @@ -79,7 +79,7 @@ public class ImplicitSummaries extends Processor { addedSummaryField.setTransform(SummaryTransform.ATTRIBUTE); } if (attribute.isPrefetch()) { - addPrefetchAttribute(attribute, field, search); + addPrefetchAttribute(attribute, field, schema); } } } @@ -92,7 +92,7 @@ public class ImplicitSummaries extends Processor { if (field.doesSummarying()) { for (Attribute attribute : field.getAttributes().values()) { if ( ! attribute.isPosition()) continue; - DocumentSummary attributePrefetchSummary = getOrCreateAttributePrefetchSummary(search); + DocumentSummary attributePrefetchSummary = getOrCreateAttributePrefetchSummary(schema); attributePrefetchSummary.add(field.getSummaryField(PositionDataType.getDistanceSummaryFieldName(fieldName))); attributePrefetchSummary.add(field.getSummaryField(PositionDataType.getPositionSummaryFieldName(fieldName))); } @@ -106,35 +106,35 @@ public class ImplicitSummaries extends Processor { summaryField.setTransform(SummaryTransform.ATTRIBUTE); } - if (isValid(summaryField, search, validate)) { - addToDestinations(summaryField, search); + if (isValid(summaryField, schema, validate)) { + addToDestinations(summaryField, schema); } } } - private DocumentSummary getOrCreateAttributePrefetchSummary(Search search) { - DocumentSummary summary = search.getSummary("attributeprefetch"); + private DocumentSummary getOrCreateAttributePrefetchSummary(Schema schema) { + DocumentSummary summary = schema.getSummary("attributeprefetch"); if (summary == null) { - summary = new DocumentSummary("attributeprefetch", search); - search.addSummary(summary); + summary = new DocumentSummary("attributeprefetch", schema); + schema.addSummary(summary); } return summary; } - private void addPrefetchAttribute(Attribute attribute,SDField field,Search search) { + private void addPrefetchAttribute(Attribute attribute, SDField field, Schema schema) { if (attribute.getPrefetchValue() == null) { // Prefetch by default - unless any summary makes this dynamic // Check if there is an implicit dynamic definition SummaryField fieldSummaryField = field.getSummaryField(attribute.getName()); if (fieldSummaryField != null && fieldSummaryField.getTransform().isDynamic()) return; // Check if an explicit class makes it dynamic (first is enough, as all must be the same, checked later) - SummaryField explicitSummaryField = search.getExplicitSummaryField(attribute.getName()); + SummaryField explicitSummaryField = schema.getExplicitSummaryField(attribute.getName()); if (explicitSummaryField != null && explicitSummaryField.getTransform().isDynamic()) return; } - DocumentSummary summary = getOrCreateAttributePrefetchSummary(search); + DocumentSummary summary = getOrCreateAttributePrefetchSummary(schema); SummaryField attributeSummaryField = new SummaryField(attribute.getName(), attribute.getDataType()); attributeSummaryField.addSource(attribute.getName()); attributeSummaryField.addDestination("attributeprefetch"); @@ -143,26 +143,26 @@ public class ImplicitSummaries extends Processor { } // Returns whether this is valid. Warns if invalid and ignorable. Throws if not ignorable. - private boolean isValid(SummaryField summaryField, Search search, boolean validate) { + private boolean isValid(SummaryField summaryField, Schema schema, boolean validate) { if (summaryField.getTransform() == SummaryTransform.DISTANCE || summaryField.getTransform() == SummaryTransform.POSITIONS) { int sourceCount = summaryField.getSourceCount(); if (validate && sourceCount != 1) { - throw newProcessException(search.getName(), summaryField.getName(), + throw newProcessException(schema.getName(), summaryField.getName(), "Expected 1 source field, got " + sourceCount + "."); } String sourceName = summaryField.getSingleSource(); - if (validate && search.getAttribute(sourceName) == null) { - throw newProcessException(search.getName(), summaryField.getName(), + if (validate && schema.getAttribute(sourceName) == null) { + throw newProcessException(schema.getName(), summaryField.getName(), "Summary source attribute '" + sourceName + "' not found."); } return true; } String fieldName = summaryField.getSourceField(); - SDField sourceField = search.getConcreteField(fieldName); + SDField sourceField = schema.getConcreteField(fieldName); if (validate && sourceField == null) { - throw newProcessException(search, summaryField, "Source field '" + fieldName + "' does not exist."); + throw newProcessException(schema, summaryField, "Source field '" + fieldName + "' does not exist."); } if (! sourceField.doesSummarying() && ! summaryField.getTransform().equals(SummaryTransform.ATTRIBUTE) && @@ -199,21 +199,21 @@ public class ImplicitSummaries extends Processor { return true; } - private void addToDestinations(SummaryField summaryField,Search search) { + private void addToDestinations(SummaryField summaryField, Schema schema) { if (summaryField.getDestinations().size() == 0) { - addToDestination("default", summaryField, search); + addToDestination("default", summaryField, schema); } else { for (String destinationName : summaryField.getDestinations()) - addToDestination(destinationName, summaryField, search); + addToDestination(destinationName, summaryField, schema); } } - private void addToDestination(String destinationName, SummaryField summaryField, Search search) { - DocumentSummary destination = search.getSummary(destinationName); + private void addToDestination(String destinationName, SummaryField summaryField, Schema schema) { + DocumentSummary destination = schema.getSummary(destinationName); if (destination == null) { - destination = new DocumentSummary(destinationName, search); - search.addSummary(destination); + destination = new DocumentSummary(destinationName, schema); + schema.addSummary(destination); destination.add(summaryField); } else { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ImplicitSummaryFields.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ImplicitSummaryFields.java index 0e13f38e207..ff0a0d07102 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ImplicitSummaryFields.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ImplicitSummaryFields.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.document.DataType; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.vespa.documentmodel.DocumentSummary; import com.yahoo.vespa.documentmodel.SummaryField; import com.yahoo.vespa.documentmodel.SummaryTransform; @@ -16,13 +16,13 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class ImplicitSummaryFields extends Processor { - public ImplicitSummaryFields(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public ImplicitSummaryFields(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - for (DocumentSummary docsum : search.getSummaries().values()) { + for (DocumentSummary docsum : schema.getSummariesInThis().values()) { if (docsum.getInherited() != null) continue; // Implicit fields are added to inheriting summaries through their parent addField(docsum, new SummaryField("rankfeatures", DataType.STRING, SummaryTransform.RANKFEATURES), validate); addField(docsum, new SummaryField("summaryfeatures", DataType.STRING, SummaryTransform.SUMMARYFEATURES), validate); @@ -36,4 +36,5 @@ public class ImplicitSummaryFields extends Processor { } docsum.add(field); } + } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ImportedFieldsResolver.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ImportedFieldsResolver.java index c737df5d44f..f8a28061897 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ImportedFieldsResolver.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ImportedFieldsResolver.java @@ -7,7 +7,7 @@ import com.yahoo.document.PositionDataType; import com.yahoo.searchdefinition.DocumentReference; import com.yahoo.searchdefinition.DocumentReferences; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.searchdefinition.document.ImportedComplexField; @@ -26,7 +26,7 @@ import static com.yahoo.searchdefinition.document.ComplexAttributeFieldUtils.isM import static com.yahoo.searchdefinition.document.ComplexAttributeFieldUtils.isMapOfSimpleStruct; /** - * Iterates all imported fields from SD-parsing and validates and resolves them into concrete fields from referenced document types. + * Iterates all imported fields from schema parsing and validates and resolves them into concrete fields from referenced document types. * * @author geirst */ @@ -35,15 +35,15 @@ public class ImportedFieldsResolver extends Processor { private final Map<String, ImportedField> importedFields = new LinkedHashMap<>(); private final Optional<DocumentReferences> references; - public ImportedFieldsResolver(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); - references = search.getDocument().getDocumentReferences(); + public ImportedFieldsResolver(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); + references = schema.getDocument().getDocumentReferences(); } @Override public void process(boolean validate, boolean documentsOnly) { - search.temporaryImportedFields().get().fields().forEach((name, field) -> resolveImportedField(field, validate)); - search.setImportedFields(new ImportedFields(importedFields)); + schema.temporaryImportedFields().get().fields().forEach((name, field) -> resolveImportedField(field, validate)); + schema.setImportedFields(new ImportedFields(importedFields)); } private void resolveImportedField(TemporaryImportedField importedField, boolean validate) { @@ -166,8 +166,8 @@ public class ImportedFieldsResolver extends Processor { private ImmutableSDField getTargetField(TemporaryImportedField importedField, DocumentReference reference) { String targetFieldName = importedField.targetFieldName(); - Search targetSearch = reference.targetSearch(); - ImmutableSDField targetField = targetSearch.getField(targetFieldName); + Schema targetSchema = reference.targetSearch(); + ImmutableSDField targetField = targetSchema.getField(targetFieldName); if (targetField == null) { fail(importedField, targetFieldAsString(targetFieldName, reference) + ": Not found"); } @@ -193,14 +193,15 @@ public class ImportedFieldsResolver extends Processor { } private void fail(TemporaryImportedField importedField, String msg) { - throw new IllegalArgumentException("For search '" + search.getName() + "', import field '" + importedField.fieldName() + "': " + msg); + throw new IllegalArgumentException("For " + schema + ", import field '" + + importedField.fieldName() + "': " + msg); } private void fail(TemporaryImportedField importedField, String importedNestedFieldName, String msg) { if (importedField.fieldName().equals(importedNestedFieldName)) { fail(importedField, msg); } - throw new IllegalArgumentException("For search '" + search.getName() + "', import field '" + - importedField.fieldName() + "' (nested to '" + importedNestedFieldName + "'): " + msg); + throw new IllegalArgumentException("For " + schema + ", import field '" + + importedField.fieldName() + "' (nested to '" + importedNestedFieldName + "'): " + msg); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexFieldNames.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexFieldNames.java index f0f52c49875..76e97ff0f2e 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexFieldNames.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexFieldNames.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.document.SDField; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.vespa.model.container.search.QueryProfiles; /** @@ -18,17 +18,17 @@ public class IndexFieldNames extends Processor { private static final String FIELD_NAME_REGEXP = "[a-zA-Z]\\w*"; - public IndexFieldNames(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public IndexFieldNames(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { if ( ! validate) return; - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { if ( ! field.getName().matches(FIELD_NAME_REGEXP) && ! legalDottedPositionField(field)) { - fail(search, field, " Not a legal field name. Legal expression: " + FIELD_NAME_REGEXP); + fail(schema, field, " Not a legal field name. Legal expression: " + FIELD_NAME_REGEXP); } } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexingInputs.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexingInputs.java index 6117f3097ab..e589bd8e91a 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexingInputs.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexingInputs.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.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.vespa.indexinglanguage.ExpressionConverter; import com.yahoo.vespa.indexinglanguage.ExpressionVisitor; @@ -21,13 +21,13 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class IndexingInputs extends Processor { - public IndexingInputs(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public IndexingInputs(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { ScriptExpression script = field.getIndexingScript(); if (script == null) continue; @@ -35,7 +35,7 @@ public class IndexingInputs extends Processor { script = (ScriptExpression)new DefaultToCurrentField(fieldName).convert(script); script = (ScriptExpression)new EnsureInputExpression(fieldName).convert(script); if (validate) - new VerifyInputExpression(search, field).visit(script); + new VerifyInputExpression(schema, field).visit(script); field.setIndexingScript(script); } @@ -85,11 +85,11 @@ public class IndexingInputs extends Processor { private class VerifyInputExpression extends ExpressionVisitor { - private final Search search; + private final Schema schema; private final SDField field; - public VerifyInputExpression(Search search, SDField field) { - this.search = search; + public VerifyInputExpression(Schema schema, SDField field) { + this.schema = schema; this.field = field; } @@ -97,10 +97,10 @@ public class IndexingInputs extends Processor { protected void doVisit(Expression exp) { if ( ! (exp instanceof InputExpression)) return; String inputField = ((InputExpression)exp).getFieldName(); - if (search.getField(inputField).hasFullIndexingDocprocRights()) return; + if (schema.getField(inputField).hasFullIndexingDocprocRights()) return; - fail(search, field, "Indexing script refers to field '" + inputField + "' which does not exist " + - "in document type '" + search.getDocument().getName() + "', and is not a mutable attribute."); + fail(schema, field, "Indexing script refers to field '" + inputField + "' which does not exist " + + "in document type '" + schema.getDocument().getName() + "', and is not a mutable attribute."); } } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexingOutputs.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexingOutputs.java index c1ed856bb11..1479f9d8f5a 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexingOutputs.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexingOutputs.java @@ -5,7 +5,7 @@ import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.document.DataType; import com.yahoo.document.Field; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.vespa.documentmodel.SummaryField; import com.yahoo.vespa.documentmodel.SummaryTransform; @@ -24,40 +24,40 @@ import java.util.*; */ public class IndexingOutputs extends Processor { - public IndexingOutputs(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public IndexingOutputs(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { ScriptExpression script = field.getIndexingScript(); if (script == null) continue; Set<String> summaryFields = new TreeSet<>(); - findSummaryTo(search, field, summaryFields, summaryFields); - MyConverter converter = new MyConverter(search, field, summaryFields, validate); + findSummaryTo(schema, field, summaryFields, summaryFields); + MyConverter converter = new MyConverter(schema, field, summaryFields, validate); field.setIndexingScript((ScriptExpression)converter.convert(script)); } } - public void findSummaryTo(Search search, SDField field, Set<String> dynamicSummary, Set<String> staticSummary) { - Map<String, SummaryField> summaryFields = search.getSummaryFields(field); + public void findSummaryTo(Schema schema, SDField field, Set<String> dynamicSummary, Set<String> staticSummary) { + Map<String, SummaryField> summaryFields = schema.getSummaryFields(field); if (summaryFields.isEmpty()) { fillSummaryToFromField(field, dynamicSummary, staticSummary); } else { - fillSummaryToFromSearch(search, field, summaryFields, dynamicSummary, staticSummary); + fillSummaryToFromSearch(schema, field, summaryFields, dynamicSummary, staticSummary); } } - private void fillSummaryToFromSearch(Search search, SDField field, Map<String, SummaryField> summaryFields, - Set<String> dynamicSummary, Set<String> staticSummary) { + private void fillSummaryToFromSearch(Schema schema, SDField field, Map<String, SummaryField> summaryFields, + Set<String> dynamicSummary, Set<String> staticSummary) { for (SummaryField summaryField : summaryFields.values()) { - fillSummaryToFromSummaryField(search, field, summaryField, dynamicSummary, staticSummary); + fillSummaryToFromSummaryField(schema, field, summaryField, dynamicSummary, staticSummary); } } - private void fillSummaryToFromSummaryField(Search search, SDField field, SummaryField summaryField, + private void fillSummaryToFromSummaryField(Schema schema, SDField field, SummaryField summaryField, Set<String> dynamicSummary, Set<String> staticSummary) { SummaryTransform summaryTransform = summaryField.getTransform(); String summaryName = summaryField.getName(); @@ -69,7 +69,7 @@ public class IndexingOutputs extends Processor { if (summaryTransform.isDynamic()) { DataType fieldType = field.getDataType(); if (fieldType != DataType.URI && fieldType != DataType.STRING) { - warn(search, field, "Dynamic summaries are only supported for fields of type " + + warn(schema, field, "Dynamic summaries are only supported for fields of type " + "string, ignoring summary field '" + summaryField.getName() + "' for sd field '" + field.getName() + "' of type " + fieldType.getName() + "."); @@ -94,13 +94,13 @@ public class IndexingOutputs extends Processor { private class MyConverter extends ExpressionConverter { - final Search search; + final Schema schema; final Field field; final Set<String> summaryFields; final boolean validate; - MyConverter(Search search, Field field, Set<String> summaryFields, boolean validate) { - this.search = search; + MyConverter(Schema schema, Field field, Set<String> summaryFields, boolean validate) { + this.schema = schema; this.field = field; this.summaryFields = summaryFields.isEmpty() ? Collections.singleton(field.getName()) : summaryFields; this.validate = validate; @@ -116,7 +116,7 @@ public class IndexingOutputs extends Processor { return true; // inject appropriate field name } if ( validate && ! fieldName.equals(field.getName())) { - fail(search, field, "Indexing expression '" + exp + "' attempts to write to a field other than '" + + fail(schema, field, "Indexing expression '" + exp + "' attempts to write to a field other than '" + field.getName() + "'."); } return false; diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexingValidation.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexingValidation.java index 915c2040224..eb9b561da73 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexingValidation.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexingValidation.java @@ -8,7 +8,7 @@ import com.yahoo.document.MapDataType; import com.yahoo.document.PositionDataType; import com.yahoo.document.WeightedSetDataType; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.vespa.documentmodel.SummaryField; @@ -33,16 +33,16 @@ import java.util.Set; */ public class IndexingValidation extends Processor { - IndexingValidation(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + IndexingValidation(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { if ( ! validate) return; - VerificationContext context = new VerificationContext(new MyAdapter(search)); - for (SDField field : search.allConcreteFields()) { + VerificationContext context = new VerificationContext(new MyAdapter(schema)); + for (SDField field : schema.allConcreteFields()) { ScriptExpression script = field.getIndexingScript(); try { script.verify(context); @@ -51,7 +51,7 @@ public class IndexingValidation extends Processor { converter.convert(exp); // TODO: stop doing this explicitly when visiting a script does not branch } } catch (VerificationException e) { - fail(search, field, "For expression '" + e.getExpression() + "': " + e.getMessage()); + fail(schema, field, "For expression '" + e.getExpression() + "': " + e.getMessage()); } } } @@ -94,15 +94,15 @@ public class IndexingValidation extends Processor { private static class MyAdapter implements FieldTypeAdapter { - final Search search; + final Schema schema; - MyAdapter(Search search) { - this.search = search; + MyAdapter(Schema schema) { + this.schema = schema; } @Override public DataType getInputType(Expression exp, String fieldName) { - SDField field = search.getDocumentField(fieldName); + SDField field = schema.getDocumentField(fieldName); if (field == null) { throw new VerificationException(exp, "Input field '" + fieldName + "' not found."); } @@ -114,21 +114,21 @@ public class IndexingValidation extends Processor { String fieldDesc; DataType fieldType; if (exp instanceof AttributeExpression) { - Attribute attribute = search.getAttribute(fieldName); + Attribute attribute = schema.getAttribute(fieldName); if (attribute == null) { throw new VerificationException(exp, "Attribute '" + fieldName + "' not found."); } fieldDesc = "attribute"; fieldType = attribute.getDataType(); } else if (exp instanceof IndexExpression) { - SDField field = search.getConcreteField(fieldName); + SDField field = schema.getConcreteField(fieldName); if (field == null) { throw new VerificationException(exp, "Index field '" + fieldName + "' not found."); } fieldDesc = "index field"; fieldType = field.getDataType(); } else if (exp instanceof SummaryExpression) { - SummaryField field = search.getSummaryField(fieldName); + SummaryField field = schema.getSummaryField(fieldName); if (field == null) { throw new VerificationException(exp, "Summary field '" + fieldName + "' not found."); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexingValues.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexingValues.java index 36a74147f05..815e5a42df4 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexingValues.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexingValues.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.document.Field; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.vespa.indexinglanguage.ExpressionConverter; import com.yahoo.vespa.indexinglanguage.expressions.Expression; @@ -17,15 +17,15 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class IndexingValues extends Processor { - public IndexingValues(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public IndexingValues(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { if ( ! validate) return; - for (Field field : search.getDocument().fieldSet()) { + for (Field field : schema.getDocument().fieldSet()) { SDField sdField = (SDField)field; if ( ! sdField.isExtraField()) { new RequireThatDocumentFieldsAreImmutable(field).convert(sdField.getIndexingScript()); @@ -50,7 +50,7 @@ public class IndexingValues extends Processor { @Override protected boolean shouldConvert(Expression exp) { if (exp instanceof OutputExpression && mutatedBy != null) { - throw newProcessException(search, field, + throw newProcessException(schema, field, "Indexing expression '" + mutatedBy + "' attempts to modify the value of the " + "document field '" + field.getName() + "'. Use a field outside the document " + "block instead."); diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/IntegerIndex2Attribute.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/IntegerIndex2Attribute.java index de108d4b711..ff6224d8d19 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/IntegerIndex2Attribute.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/IntegerIndex2Attribute.java @@ -6,7 +6,7 @@ import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.document.NumericDataType; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.Index; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.vespa.indexinglanguage.ExpressionConverter; import com.yahoo.vespa.indexinglanguage.ExpressionVisitor; import com.yahoo.vespa.indexinglanguage.expressions.AttributeExpression; @@ -25,13 +25,13 @@ import java.util.Set; */ public class IntegerIndex2Attribute extends Processor { - public IntegerIndex2Attribute(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public IntegerIndex2Attribute(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { if (field.doesIndexing() && field.getDataType().getPrimitiveType() instanceof NumericDataType) { if (field.getIndex(field.getName()) != null && ! (field.getIndex(field.getName()).getType().equals(Index.Type.VESPA))) continue; @@ -39,9 +39,9 @@ public class IntegerIndex2Attribute extends Processor { Set<String> attributeNames = new HashSet<>(); new MyVisitor(attributeNames).visit(script); field.setIndexingScript((ScriptExpression)new MyConverter(attributeNames).convert(script)); - warn(search, field, "Changed to attribute because numerical indexes (field has type " + + warn(schema, field, "Changed to attribute because numerical indexes (field has type " + field.getDataType().getName() + ") is not currently supported." + - " Index-only settings may fail. Ignore this warning for streaming search."); + " Index-only settings may fail. Ignore this warning for streaming search."); } } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/LiteralBoost.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/LiteralBoost.java index 51ef1c312a8..afe004fd5f3 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/LiteralBoost.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/LiteralBoost.java @@ -3,9 +3,9 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.RankProfile; -import com.yahoo.searchdefinition.Search; import com.yahoo.vespa.model.container.search.QueryProfiles; import java.util.Iterator; @@ -25,21 +25,21 @@ import java.util.Iterator; */ public class LiteralBoost extends Processor { - public LiteralBoost(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public LiteralBoost(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } /** Adds extra search fields and indices to express literal boosts */ @Override public void process(boolean validate, boolean documentsOnly) { - checkRankModifierRankType(search); - addLiteralBoostsToFields(search); - reduceFieldLiteralBoosts(search); + checkRankModifierRankType(schema); + addLiteralBoostsToFields(schema); + reduceFieldLiteralBoosts(schema); } /** Checks if literal boost is given using rank: , and set the actual literal boost accordingly. */ - private void checkRankModifierRankType(Search search) { - for (SDField field : search.allConcreteFields()) { + private void checkRankModifierRankType(Schema schema) { + for (SDField field : schema.allConcreteFields()) { if (field.getLiteralBoost() > -1) continue; // Let explicit value take precedence if (field.getRanking().isLiteral()) field.setLiteralBoost(100); @@ -51,26 +51,26 @@ public class LiteralBoost extends Processor { * This is required because boost indices will only be generated by looking * at field boosts */ - private void addLiteralBoostsToFields(Search search) { - Iterator i = matchingRankSettingsIterator(search, RankProfile.RankSetting.Type.LITERALBOOST); + private void addLiteralBoostsToFields(Schema schema) { + Iterator i = matchingRankSettingsIterator(schema, RankProfile.RankSetting.Type.LITERALBOOST); while (i.hasNext()) { RankProfile.RankSetting setting = (RankProfile.RankSetting)i.next(); - SDField field = search.getConcreteField(setting.getFieldName()); + SDField field = schema.getConcreteField(setting.getFieldName()); if (field == null) continue; if (field.getLiteralBoost() < 0) field.setLiteralBoost(0); } } - private void reduceFieldLiteralBoosts(Search search) { - for (SDField field : search.allConcreteFields()) { + private void reduceFieldLiteralBoosts(Schema schema) { + for (SDField field : schema.allConcreteFields()) { if (field.getLiteralBoost() < 0) continue; - reduceFieldLiteralBoost(field,search); + reduceFieldLiteralBoost(field, schema); } } - private void reduceFieldLiteralBoost(SDField field,Search search) { - SDField literalField = addField(search, field, "literal", + private void reduceFieldLiteralBoost(SDField field, Schema schema) { + SDField literalField = addField(schema, field, "literal", "{ input " + field.getName() + " | tokenize | index " + field.getName() + "_literal; }", "literal-boost"); literalField.setWeight(field.getWeight() + field.getLiteralBoost()); diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/MakeAliases.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/MakeAliases.java index 36371dd9295..14d75c6438e 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/MakeAliases.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/MakeAliases.java @@ -3,10 +3,10 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.Index; -import com.yahoo.searchdefinition.Search; import com.yahoo.vespa.model.container.search.QueryProfiles; import java.util.ArrayList; @@ -20,22 +20,22 @@ import java.util.Map; */ public class MakeAliases extends Processor { - public MakeAliases(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public MakeAliases(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { List<String> usedAliases = new ArrayList<>(); - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { for (Map.Entry<String, String> e : field.getAliasToName().entrySet()) { String alias = e.getKey(); String name = e.getValue(); - String errMsg = "For search '" + search.getName() + "': alias '" + alias + "' "; - if (validate && search.existsIndex(alias)) { + String errMsg = "For " + schema + ": alias '" + alias + "' "; + if (validate && schema.existsIndex(alias)) { throw new IllegalArgumentException(errMsg + "is illegal since it is the name of an index."); } - if (validate && search.getAttribute(alias) != null) { + if (validate && schema.getAttribute(alias) != null) { throw new IllegalArgumentException(errMsg + "is illegal since it is the name of an attribute."); } if (validate && usedAliases.contains(alias)) { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/MakeDefaultSummaryTheSuperSet.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/MakeDefaultSummaryTheSuperSet.java index 3524f5666b3..a82c8d0c6be 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/MakeDefaultSummaryTheSuperSet.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/MakeDefaultSummaryTheSuperSet.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.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.vespa.documentmodel.DocumentSummary; import com.yahoo.vespa.documentmodel.SummaryField; import com.yahoo.vespa.documentmodel.SummaryTransform; @@ -29,14 +29,14 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class MakeDefaultSummaryTheSuperSet extends Processor { - public MakeDefaultSummaryTheSuperSet(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public MakeDefaultSummaryTheSuperSet(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - DocumentSummary defaultSummary=search.getSummary("default"); - for (SummaryField summaryField : search.getUniqueNamedSummaryFields().values() ) { + DocumentSummary defaultSummary= schema.getSummary("default"); + for (SummaryField summaryField : schema.getUniqueNamedSummaryFields().values() ) { if (defaultSummary.getSummaryField(summaryField.getName()) != null) continue; if (summaryField.getTransform() == SummaryTransform.ATTRIBUTE) continue; if (summaryField.getTransform() == SummaryTransform.ATTRIBUTECOMBINER) continue; diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchConsistency.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchConsistency.java index d9c62967649..c302ef63cfd 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchConsistency.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchConsistency.java @@ -3,10 +3,10 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Matching; import com.yahoo.searchdefinition.document.Matching.Type; import com.yahoo.searchdefinition.document.SDField; -import com.yahoo.searchdefinition.Search; import com.yahoo.vespa.indexinglanguage.ExpressionVisitor; import com.yahoo.vespa.indexinglanguage.expressions.Expression; import com.yahoo.vespa.indexinglanguage.expressions.IndexExpression; @@ -22,11 +22,11 @@ import java.util.Map; */ public class MatchConsistency extends Processor { - public MatchConsistency(Search search, + public MatchConsistency(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override @@ -34,17 +34,17 @@ public class MatchConsistency extends Processor { if ( ! validate) return; Map<String, Matching.Type> types = new HashMap<>(); - for (SDField field : search.allConcreteFields()) { - new MyVisitor(search, field, types).visit(field.getIndexingScript()); + for (SDField field : schema.allConcreteFields()) { + new MyVisitor(schema, field, types).visit(field.getIndexingScript()); } } - private void checkMatching(Search search, SDField field, Map<String, Type> types, String indexTo) { + private void checkMatching(Schema schema, SDField field, Map<String, Type> types, String indexTo) { Type prevType = types.get(indexTo); if (prevType == null) { types.put(indexTo, field.getMatching().getType()); } else if ( ! field.getMatching().getType().equals(prevType)) { - warn(search, field, "The matching type for index '" + indexTo + "' (got " + field.getMatching().getType() + + warn(schema, field, "The matching type for index '" + indexTo + "' (got " + field.getMatching().getType() + ") is inconsistent with that given for the same index in a previous field (had " + prevType + ")."); } @@ -52,12 +52,12 @@ public class MatchConsistency extends Processor { private class MyVisitor extends ExpressionVisitor { - final Search search; + final Schema schema; final SDField field; final Map<String, Type> types; - MyVisitor(Search search, SDField field, Map<String, Type> types) { - this.search = search; + MyVisitor(Schema schema, SDField field, Map<String, Type> types) { + this.schema = schema; this.field = field; this.types = types; } @@ -65,7 +65,7 @@ public class MatchConsistency extends Processor { @Override protected void doVisit(Expression exp) { if (exp instanceof IndexExpression) { - checkMatching(search, field, types, ((IndexExpression)exp).getFieldName()); + checkMatching(schema, field, types, ((IndexExpression)exp).getFieldName()); } } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchPhaseSettingsValidator.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchPhaseSettingsValidator.java index 8afc85f2e1f..b697c584ece 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchPhaseSettingsValidator.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchPhaseSettingsValidator.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.vespa.model.container.search.QueryProfiles; @@ -15,8 +15,8 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class MatchPhaseSettingsValidator extends Processor { - public MatchPhaseSettingsValidator(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public MatchPhaseSettingsValidator(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override @@ -24,7 +24,7 @@ public class MatchPhaseSettingsValidator extends Processor { if ( ! validate) return; if (documentsOnly) return; - for (RankProfile rankProfile : rankProfileRegistry.rankProfilesOf(search)) { + for (RankProfile rankProfile : rankProfileRegistry.rankProfilesOf(schema)) { RankProfile.MatchPhaseSettings settings = rankProfile.getMatchPhaseSettings(); if (settings != null) { validateMatchPhaseSettings(rankProfile, settings); @@ -34,9 +34,9 @@ public class MatchPhaseSettingsValidator extends Processor { private void validateMatchPhaseSettings(RankProfile rankProfile, RankProfile.MatchPhaseSettings settings) { String attributeName = settings.getAttribute(); - new AttributeValidator(search.getName(), + new AttributeValidator(schema.getName(), rankProfile.getName(), - search.getAttribute(attributeName), attributeName).validate(); + schema.getAttribute(attributeName), attributeName).validate(); } public static class AttributeValidator { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolver.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolver.java index 77064038053..709c79cd79b 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolver.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/MatchedElementsOnlyResolver.java @@ -6,7 +6,7 @@ import com.yahoo.document.ArrayDataType; import com.yahoo.document.DataType; import com.yahoo.document.WeightedSetDataType; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.ComplexAttributeFieldUtils; import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.vespa.documentmodel.DocumentSummary; @@ -25,13 +25,13 @@ import static com.yahoo.searchdefinition.document.ComplexAttributeFieldUtils.isS */ public class MatchedElementsOnlyResolver extends Processor { - public MatchedElementsOnlyResolver(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public MatchedElementsOnlyResolver(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - for (var entry : search.getSummaries().entrySet()) { + for (var entry : schema.getSummaries().entrySet()) { var summary = entry.getValue(); for (var field : summary.getSummaryFields()) { if (field.getTransform().equals(SummaryTransform.MATCHED_ELEMENTS_FILTER)) { @@ -42,7 +42,7 @@ public class MatchedElementsOnlyResolver extends Processor { } private void processSummaryField(DocumentSummary summary, SummaryField field, boolean validate) { - var sourceField = search.getField(field.getSingleSource()); + var sourceField = schema.getField(field.getSingleSource()); if (sourceField != null) { if (isSupportedComplexField(sourceField)) { if (isComplexFieldWithOnlyStructFieldAttributes(sourceField)) { @@ -84,12 +84,12 @@ public class MatchedElementsOnlyResolver extends Processor { } private void fail(DocumentSummary summary, SummaryField field, String msg) { - throw new IllegalArgumentException(formatError(search, summary, field, msg)); + throw new IllegalArgumentException(formatError(schema, summary, field, msg)); } - private String formatError(Search search, DocumentSummary summary, SummaryField field, String msg) { - return "For search '" + search.getName() + "', document summary '" + summary.getName() - + "', summary field '" + field.getName() + "': " + msg; + private String formatError(Schema schema, DocumentSummary summary, SummaryField field, String msg) { + return "For " + schema + ", document summary '" + summary.getName() + + "', summary field '" + field.getName() + "': " + msg; } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/MultifieldIndexHarmonizer.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/MultifieldIndexHarmonizer.java index 265715e8eb9..39220b8cf8f 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/MultifieldIndexHarmonizer.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/MultifieldIndexHarmonizer.java @@ -3,8 +3,8 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.SDField; -import com.yahoo.searchdefinition.Search; import com.yahoo.searchdefinition.processing.multifieldresolver.IndexCommandResolver; import com.yahoo.searchdefinition.processing.multifieldresolver.RankTypeResolver; import com.yahoo.searchdefinition.processing.multifieldresolver.StemmingResolver; @@ -25,18 +25,18 @@ public class MultifieldIndexHarmonizer extends Processor { /** A map from index names to a List of fields going to that index */ private Map<String,List<SDField>> indexToFields=new java.util.HashMap<>(); - public MultifieldIndexHarmonizer(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public MultifieldIndexHarmonizer(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - populateIndexToFields(search); - resolveAllConflicts(search); + populateIndexToFields(schema); + resolveAllConflicts(schema); } - private void populateIndexToFields(Search search) { - for (SDField field : search.allConcreteFields() ) { + private void populateIndexToFields(Schema schema) { + for (SDField field : schema.allConcreteFields() ) { if ( ! field.doesIndexing()) continue; addIndexField(field.getName(), field); } @@ -51,12 +51,12 @@ public class MultifieldIndexHarmonizer extends Processor { fields.add(field); } - private void resolveAllConflicts(Search search) { + private void resolveAllConflicts(Schema schema) { for (Map.Entry<String, List<SDField>> entry : indexToFields.entrySet()) { String indexName = entry.getKey(); List<SDField> fields = entry.getValue(); if (fields.size() == 1) continue; // It takes two to make a conflict - resolveConflicts(indexName, fields, search); + resolveConflicts(indexName, fields, schema); } } @@ -65,12 +65,12 @@ public class MultifieldIndexHarmonizer extends Processor { * * @param indexName the name of the index in question * @param fields all the fields indexed to this index - * @param search the search definition having this + * @param schema the search definition having this */ - private void resolveConflicts(String indexName,List<SDField> fields,Search search) { - new StemmingResolver(indexName, fields, search, deployLogger).resolve(); - new IndexCommandResolver(indexName, fields, search, deployLogger).resolve(); - new RankTypeResolver(indexName, fields, search, deployLogger).resolve(); + private void resolveConflicts(String indexName, List<SDField> fields, Schema schema) { + new StemmingResolver(indexName, fields, schema, deployLogger).resolve(); + new IndexCommandResolver(indexName, fields, schema, deployLogger).resolve(); + new RankTypeResolver(indexName, fields, schema, deployLogger).resolve(); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/MutableAttributes.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/MutableAttributes.java index 35b17234a1d..198f89caddb 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/MutableAttributes.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/MutableAttributes.java @@ -3,24 +3,24 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.vespa.model.container.search.QueryProfiles; public class MutableAttributes extends Processor { - public MutableAttributes(Search search, DeployLogger deployLogger, + public MutableAttributes(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { if ( ! field.isExtraField() && field.getAttributes().containsKey(field.getName())) { if (field.getAttributes().get(field.getName()).isMutable()) { - throw new IllegalArgumentException("Field '" + field.getName() + "' in '" + search.getDocument().getName() + + throw new IllegalArgumentException("Field '" + field.getName() + "' in '" + schema.getDocument().getName() + "' can not be marked mutable as it is inside the document clause."); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/NGramMatch.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/NGramMatch.java index 0995762da6e..b5f573ecf71 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/NGramMatch.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/NGramMatch.java @@ -5,7 +5,7 @@ import com.yahoo.config.application.api.DeployLogger; import com.yahoo.document.CollectionDataType; import com.yahoo.document.DataType; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Matching; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.document.Stemming; @@ -22,21 +22,21 @@ public class NGramMatch extends Processor { public static final int DEFAULT_GRAM_SIZE = 2; - public NGramMatch(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public NGramMatch(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { if (field.getMatching().getType().equals(Matching.Type.GRAM)) - implementGramMatch(search, field, validate); + implementGramMatch(schema, field, validate); else if (validate && field.getMatching().getGramSize() >= 0) throw new IllegalArgumentException("gram-size can only be set when the matching mode is 'gram'"); } } - private void implementGramMatch(Search search, SDField field, boolean validate) { + private void implementGramMatch(Schema schema, SDField field, boolean validate) { if (validate && field.doesAttributing() && ! field.doesIndexing()) throw new IllegalArgumentException("gram matching is not supported with attributes, use 'index' in indexing"); @@ -48,15 +48,15 @@ public class NGramMatch extends Processor { field.getNormalizing().inferCodepoint(); field.setStemming(Stemming.NONE); // not compatible with stemming and normalizing field.addQueryCommand("ngram " + n); - field.setIndexingScript((ScriptExpression)new MyProvider(search, n).convert(field.getIndexingScript())); + field.setIndexingScript((ScriptExpression)new MyProvider(schema, n).convert(field.getIndexingScript())); } private static class MyProvider extends TypedTransformProvider { final int ngram; - MyProvider(Search search, int ngram) { - super(NGramExpression.class, search); + MyProvider(Schema schema, int ngram) { + super(NGramExpression.class, schema); this.ngram = ngram; } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/OnnxModelConfigGenerator.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/OnnxModelConfigGenerator.java index a2eae585a25..c7c1db3b862 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/OnnxModelConfigGenerator.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/OnnxModelConfigGenerator.java @@ -7,7 +7,7 @@ import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.OnnxModel; import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.expressiontransforms.OnnxModelTransformer; import com.yahoo.searchlib.rankingexpression.rule.CompositeNode; import com.yahoo.searchlib.rankingexpression.rule.ConstantNode; @@ -36,14 +36,14 @@ import java.util.Map; */ public class OnnxModelConfigGenerator extends Processor { - public OnnxModelConfigGenerator(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public OnnxModelConfigGenerator(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { if (documentsOnly) return; - for (RankProfile profile : rankProfileRegistry.rankProfilesOf(search)) { + for (RankProfile profile : rankProfileRegistry.rankProfilesOf(schema)) { if (profile.getFirstPhaseRanking() != null) { process(profile.getFirstPhaseRanking().getRoot()); } @@ -78,17 +78,17 @@ public class OnnxModelConfigGenerator extends Processor { String modelConfigName = OnnxModelTransformer.asValidIdentifier(path); // Only add the configuration if the model can actually be found. - if ( ! OnnxModelInfo.modelExists(path, search.applicationPackage())) { + if ( ! OnnxModelInfo.modelExists(path, schema.applicationPackage())) { path = ApplicationPackage.MODELS_DIR.append(path).toString(); - if ( ! OnnxModelInfo.modelExists(path, search.applicationPackage())) { + if ( ! OnnxModelInfo.modelExists(path, schema.applicationPackage())) { return; } } - OnnxModel onnxModel = search.onnxModels().get(modelConfigName); + OnnxModel onnxModel = schema.onnxModels().get(modelConfigName); if (onnxModel == null) { onnxModel = new OnnxModel(modelConfigName, path); - search.onnxModels().add(onnxModel); + schema.onnxModels().add(onnxModel); } } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/OnnxModelTypeResolver.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/OnnxModelTypeResolver.java index aa3c5db4e83..4153cca4b5b 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/OnnxModelTypeResolver.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/OnnxModelTypeResolver.java @@ -5,7 +5,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.OnnxModel; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.vespa.model.container.search.QueryProfiles; import com.yahoo.vespa.model.ml.OnnxModelInfo; @@ -21,15 +21,15 @@ import com.yahoo.vespa.model.ml.OnnxModelInfo; */ public class OnnxModelTypeResolver extends Processor { - public OnnxModelTypeResolver(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public OnnxModelTypeResolver(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { if (documentsOnly) return; - for (OnnxModel onnxModel : search.onnxModels().asMap().values()) { - OnnxModelInfo onnxModelInfo = OnnxModelInfo.load(onnxModel.getFileName(), search.applicationPackage()); + for (OnnxModel onnxModel : schema.onnxModels().asMap().values()) { + OnnxModelInfo onnxModelInfo = OnnxModelInfo.load(onnxModel.getFileName(), schema.applicationPackage()); onnxModel.setModelInfo(onnxModelInfo); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/OptimizeIlscript.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/OptimizeIlscript.java index 82bcff265c0..3175862e900 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/OptimizeIlscript.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/OptimizeIlscript.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.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.vespa.indexinglanguage.ExpressionOptimizer; import com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression; @@ -14,22 +14,22 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class OptimizeIlscript extends Processor { - public OptimizeIlscript(Search search, + public OptimizeIlscript(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { ScriptExpression script = field.getIndexingScript(); if (script == null) continue; field.setIndexingScript((ScriptExpression)new ExpressionOptimizer().convert(script)); if ( ! field.getIndexingScript().toString().equals(script.toString())) { - info(search, field, "Rewrote ilscript from:\n" + script.toString() + + info(schema, field, "Rewrote ilscript from:\n" + script.toString() + "\nto\n" + field.getIndexingScript().toString()); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/PagedAttributeValidator.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/PagedAttributeValidator.java index 5e344f5a824..d108a620fd9 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/PagedAttributeValidator.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/PagedAttributeValidator.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.document.Field; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.tensor.TensorType; import com.yahoo.vespa.model.container.search.QueryProfiles; @@ -17,11 +17,11 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; public class PagedAttributeValidator extends Processor { - public PagedAttributeValidator(Search search, + public PagedAttributeValidator(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override @@ -29,7 +29,7 @@ public class PagedAttributeValidator extends Processor { if (!validate) { return; } - for (var field : search.allConcreteFields()) { + for (var field : schema.allConcreteFields()) { for (var attribute : field.getAttributes().values()) { if (attribute.isPaged()) { validatePagedSetting(field, attribute); @@ -42,7 +42,7 @@ public class PagedAttributeValidator extends Processor { var tensorType = attribute.tensorType(); if (!tensorType.isPresent() || !isDenseTensorType(tensorType.get())) { - fail(search, field, "The 'paged' attribute setting is only supported for dense tensor types"); + fail(schema, field, "The 'paged' attribute setting is only supported for dense tensor types"); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/PredicateProcessor.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/PredicateProcessor.java index df357d6b704..73b75d6e23a 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/PredicateProcessor.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/PredicateProcessor.java @@ -7,7 +7,7 @@ import com.yahoo.document.DataType; import com.yahoo.document.datatypes.IntegerFieldValue; import com.yahoo.document.datatypes.LongFieldValue; import com.yahoo.searchdefinition.Index; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.document.BooleanIndexDefinition; import com.yahoo.searchdefinition.document.SDField; @@ -34,30 +34,30 @@ import java.util.List; */ public class PredicateProcessor extends Processor { - public PredicateProcessor(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public PredicateProcessor(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { if (field.getDataType() == DataType.PREDICATE) { if (validate && field.doesIndexing()) { - fail(search, field, "Use 'attribute' instead of 'index'. This will require a refeed if you have upgraded."); + fail(schema, field, "Use 'attribute' instead of 'index'. This will require a refeed if you have upgraded."); } if (field.doesAttributing()) { Attribute attribute = field.getAttributes().get(field.getName()); for (Index index : field.getIndices().values()) { BooleanIndexDefinition booleanDefinition = index.getBooleanIndexDefiniton(); if (validate && (booleanDefinition == null || ! booleanDefinition.hasArity())) { - fail(search, field, "Missing arity value in predicate field."); + fail(schema, field, "Missing arity value in predicate field."); } if (validate && (booleanDefinition.getArity() < 2)) { - fail(search, field, "Invalid arity value in predicate field, must be greater than 1."); + fail(schema, field, "Invalid arity value in predicate field, must be greater than 1."); } double threshold = booleanDefinition.getDensePostingListThreshold(); if (validate && (threshold <= 0 || threshold > 1)) { - fail(search, field, "Invalid dense-posting-list-threshold value in predicate field. " + + fail(schema, field, "Invalid dense-posting-list-threshold value in predicate field. " + "Value must be in range (0..1]."); } @@ -68,29 +68,29 @@ public class PredicateProcessor extends Processor { attribute.setDensePostingListThreshold(threshold); addPredicateOptimizationIlScript(field, booleanDefinition); } - DocumentSummary summary = search.getSummary("attributeprefetch"); + DocumentSummary summary = schema.getSummary("attributeprefetch"); if (summary != null) { summary.remove(attribute.getName()); } - for (SummaryField summaryField : search.getSummaryFields(field).values()) { + for (SummaryField summaryField : schema.getSummaryFields(field).values()) { summaryField.setTransform(SummaryTransform.NONE); } } } else if (validate && field.getDataType().getPrimitiveType() == DataType.PREDICATE) { - fail(search, field, "Collections of predicates are not allowed."); + fail(schema, field, "Collections of predicates are not allowed."); } else if (validate && field.getDataType() == DataType.RAW && field.doesIndexing()) { - fail(search, field, "Indexing of RAW fields is not supported."); + fail(schema, field, "Indexing of RAW fields is not supported."); } else if (validate) { // if field is not a predicate, disallow predicate-related index parameters for (Index index : field.getIndices().values()) { if (index.getBooleanIndexDefiniton() != null) { BooleanIndexDefinition def = index.getBooleanIndexDefiniton(); if (def.hasArity()) { - fail(search, field, "Arity parameter is used only for predicate type fields."); + fail(schema, field, "Arity parameter is used only for predicate type fields."); } else if (def.hasLowerBound() || def.hasUpperBound()) { - fail(search, field, "Parameters lower-bound and upper-bound are used only for predicate type fields."); + fail(schema, field, "Parameters lower-bound and upper-bound are used only for predicate type fields."); } else if (def.hasDensePostingListThreshold()) { - fail(search, field, "Parameter dense-posting-list-threshold is used only for predicate type fields."); + fail(schema, field, "Parameter dense-posting-list-threshold is used only for predicate type fields."); } } } @@ -104,7 +104,7 @@ public class PredicateProcessor extends Processor { script = new StatementExpression(makeSetPredicateVariablesScript(booleanIndexDefiniton), script); - ExpressionConverter converter = new PredicateOutputTransformer(search); + ExpressionConverter converter = new PredicateOutputTransformer(schema); field.setIndexingScript(new ScriptExpression((StatementExpression)converter.convert(script))); } @@ -125,8 +125,8 @@ public class PredicateProcessor extends Processor { private static class PredicateOutputTransformer extends TypedTransformProvider { - PredicateOutputTransformer(Search search) { - super(OptimizePredicateExpression.class, search); + PredicateOutputTransformer(Schema schema) { + super(OptimizePredicateExpression.class, schema); } @Override diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/Processing.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/Processing.java index ddb158a3d84..a484476e978 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/Processing.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/Processing.java @@ -3,12 +3,13 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.processing.multifieldresolver.RankProfileTypeSettingsProcessor; import com.yahoo.vespa.model.container.search.QueryProfiles; import java.util.Arrays; import java.util.Collection; +import java.util.Set; /** * Executor of processors. This defines the right order of processor execution. @@ -94,31 +95,34 @@ public class Processing { } /** - * Runs all search processors on the given {@link Search} object. These will modify the search object, <b>possibly + * Runs all search processors on the given {@link Schema} object. These will modify the search object, <b>possibly * exchanging it with another</b>, as well as its document types. * - * @param search The search to process. - * @param deployLogger The log to log messages and warnings for application deployment to + * @param schema the search to process + * @param deployLogger the log to log messages and warnings for application deployment to * @param rankProfileRegistry a {@link com.yahoo.searchdefinition.RankProfileRegistry} - * @param queryProfiles The query profiles contained in the application this search is part of. + * @param queryProfiles the query profiles contained in the application this search is part of + * @param processorsToSkip a set of processor classes we should not invoke in this. Useful for testing. */ - public void process(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, - QueryProfiles queryProfiles, boolean validate, boolean documentsOnly) { + public void process(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, + QueryProfiles queryProfiles, boolean validate, boolean documentsOnly, + Set<Class<? extends Processor>> processorsToSkip) { Collection<ProcessorFactory> factories = processors(); factories.stream() - .map(factory -> factory.create(search, deployLogger, rankProfileRegistry, queryProfiles)) + .map(factory -> factory.create(schema, deployLogger, rankProfileRegistry, queryProfiles)) + .filter(processor -> ! processorsToSkip.contains(processor.getClass())) .forEach(processor -> processor.process(validate, documentsOnly)); } /** * Runs rank profiles processors only. * - * @param deployLogger The log to log messages and warnings for application deployment to + * @param deployLogger the log to log messages and warnings for application deployment to * @param rankProfileRegistry a {@link com.yahoo.searchdefinition.RankProfileRegistry} - * @param queryProfiles The query profiles contained in the application this search is part of. + * @param queryProfiles the query profiles contained in the application this search is part of */ public void processRankProfiles(DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, - QueryProfiles queryProfiles, boolean validate, boolean documentsOnly) { + QueryProfiles queryProfiles, boolean validate, boolean documentsOnly) { Collection<ProcessorFactory> factories = rankProfileProcessors(); factories.stream() .map(factory -> factory.create(null, deployLogger, rankProfileRegistry, queryProfiles)) @@ -127,7 +131,8 @@ public class Processing { @FunctionalInterface public interface ProcessorFactory { - Processor create(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles); + Processor create(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, + QueryProfiles queryProfiles); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/Processor.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/Processor.java index c4f15367831..e8f60335362 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/Processor.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/Processor.java @@ -7,7 +7,7 @@ import com.yahoo.document.Field; import com.yahoo.searchdefinition.Index; import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.RankType; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.document.Stemming; @@ -24,7 +24,7 @@ import java.util.logging.Level; */ public abstract class Processor { - protected final Search search; + protected final Schema schema; protected final DeployLogger deployLogger; protected final RankProfileRegistry rankProfileRegistry; protected final QueryProfiles queryProfiles; @@ -32,16 +32,16 @@ public abstract class Processor { /** * Base constructor * - * @param search the search to process + * @param schema the search to process * @param deployLogger Logger du use when logging deploy output. * @param rankProfileRegistry Registry with all rank profiles, used for lookup and insertion. * @param queryProfiles The query profiles contained in the application this search is part of. */ - public Processor(Search search, + public Processor(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - this.search = search; + this.schema = schema; this.deployLogger = deployLogger; this.rankProfileRegistry = rankProfileRegistry; this.queryProfiles = queryProfiles; @@ -62,19 +62,19 @@ public abstract class Processor { /** * Convenience method for adding a no-strings-attached implementation field for a regular field * - * @param search the search definition in question + * @param schema the search definition in question * @param field the field to add an implementation field for * @param suffix the suffix of the added implementation field (without the underscore) * @param indexing the indexing statement of the field * @param queryCommand the query command of the original field, or null if none * @return the implementation field which is added to the search */ - protected SDField addField(Search search, SDField field, String suffix, String indexing, String queryCommand) { - SDField implementationField = search.getConcreteField(field.getName() + "_" + suffix); + protected SDField addField(Schema schema, SDField field, String suffix, String indexing, String queryCommand) { + SDField implementationField = schema.getConcreteField(field.getName() + "_" + suffix); if (implementationField != null) { deployLogger.logApplicationPackage(Level.WARNING, "Implementation field " + implementationField + " added twice"); } else { - implementationField = new SDField(search.getDocument(), field.getName() + "_" + suffix, DataType.STRING); + implementationField = new SDField(schema.getDocument(), field.getName() + "_" + suffix, DataType.STRING); } implementationField.setRankType(RankType.EMPTY); implementationField.setStemming(Stemming.NONE); @@ -83,12 +83,12 @@ public abstract class Processor { String indexName = field.getName(); String implementationIndexName = indexName + "_" + suffix; Index implementationIndex = new Index(implementationIndexName); - search.addIndex(implementationIndex); + schema.addIndex(implementationIndex); if (queryCommand != null) { field.addQueryCommand(queryCommand); } - search.addExtraField(implementationField); - search.fieldSets().addBuiltInFieldSetItem(BuiltInFieldSets.INTERNAL_FIELDSET_NAME, implementationField.getName()); + schema.addExtraField(implementationField); + schema.fieldSets().addBuiltInFieldSetItem(BuiltInFieldSets.INTERNAL_FIELDSET_NAME, implementationField.getName()); return implementationField; } @@ -97,11 +97,11 @@ public abstract class Processor { * definition. */ protected Iterator<RankProfile.RankSetting> matchingRankSettingsIterator( - Search search, RankProfile.RankSetting.Type type) + Schema schema, RankProfile.RankSetting.Type type) { List<RankProfile.RankSetting> someRankSettings = new java.util.ArrayList<>(); - for (RankProfile profile : rankProfileRegistry.rankProfilesOf(search)) { + for (RankProfile profile : rankProfileRegistry.rankProfilesOf(schema)) { for (Iterator j = profile.declaredRankSettingIterator(); j.hasNext(); ) { RankProfile.RankSetting setting = (RankProfile.RankSetting)j.next(); if (setting.getType().equals(type)) { @@ -112,38 +112,38 @@ public abstract class Processor { return someRankSettings.iterator(); } - protected String formatError(String searchName, String fieldName, String msg) { - return "For search '" + searchName + "', field '" + fieldName + "': " + msg; + protected String formatError(String schemaName, String fieldName, String msg) { + return "For schema '" + schemaName + "', field '" + fieldName + "': " + msg; } - protected RuntimeException newProcessException(String searchName, String fieldName, String msg) { - return new IllegalArgumentException(formatError(searchName, fieldName, msg)); + protected RuntimeException newProcessException(String schemaName, String fieldName, String msg) { + return new IllegalArgumentException(formatError(schemaName, fieldName, msg)); } - protected RuntimeException newProcessException(Search search, Field field, String msg) { - return newProcessException(search.getName(), field.getName(), msg); + protected RuntimeException newProcessException(Schema schema, Field field, String msg) { + return newProcessException(schema.getName(), field.getName(), msg); } - public void fail(Search search, Field field, String msg) { - throw newProcessException(search, field, msg); + public void fail(Schema schema, Field field, String msg) { + throw newProcessException(schema, field, msg); } - protected void warn(String searchName, String fieldName, String message) { - String fullMsg = formatError(searchName, fieldName, message); + protected void warn(String schemaName, String fieldName, String message) { + String fullMsg = formatError(schemaName, fieldName, message); deployLogger.logApplicationPackage(Level.WARNING, fullMsg); } - protected void warn(Search search, Field field, String message) { - warn(search.getName(), field.getName(), message); + protected void warn(Schema schema, Field field, String message) { + warn(schema.getName(), field.getName(), message); } - protected void info(String searchName, String fieldName, String message) { - String fullMsg = formatError(searchName, fieldName, message); + protected void info(String schemaName, String fieldName, String message) { + String fullMsg = formatError(schemaName, fieldName, message); deployLogger.logApplicationPackage(Level.INFO, fullMsg); } - protected void info(Search search, Field field, String message) { - info(search.getName(), field.getName(), message); + protected void info(Schema schema, Field field, String message) { + info(schema.getName(), field.getName(), message); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolver.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolver.java index e6b58cb6c12..f5c3fa35e34 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolver.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/RankingExpressionTypeResolver.java @@ -6,7 +6,7 @@ import com.yahoo.search.query.profile.QueryProfileRegistry; import com.yahoo.searchdefinition.MapEvaluationTypeContext; import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchlib.rankingexpression.ExpressionFunction; import com.yahoo.searchlib.rankingexpression.RankingExpression; import com.yahoo.searchlib.rankingexpression.Reference; @@ -15,7 +15,6 @@ import com.yahoo.tensor.TensorType; import com.yahoo.tensor.evaluation.TypeContext; import com.yahoo.vespa.model.container.search.QueryProfiles; -import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -36,11 +35,11 @@ public class RankingExpressionTypeResolver extends Processor { private final QueryProfileRegistry queryProfiles; - public RankingExpressionTypeResolver(Search search, + public RankingExpressionTypeResolver(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + super(schema, deployLogger, rankProfileRegistry, queryProfiles); this.queryProfiles = queryProfiles.getRegistry(); } @@ -49,12 +48,12 @@ public class RankingExpressionTypeResolver extends Processor { if (documentsOnly) return; Set<Reference> warnedAbout = new HashSet<>(); - for (RankProfile profile : rankProfileRegistry.rankProfilesOf(search)) { + for (RankProfile profile : rankProfileRegistry.rankProfilesOf(schema)) { try { resolveTypesIn(profile, validate, warnedAbout); } catch (IllegalArgumentException e) { - throw new IllegalArgumentException("In " + (search != null ? search + ", " : "") + profile, e); + throw new IllegalArgumentException("In " + (schema != null ? schema + ", " : "") + profile, e); } } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReferenceFieldsProcessor.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReferenceFieldsProcessor.java index 698e654f1cb..ed23b1ca606 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReferenceFieldsProcessor.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReferenceFieldsProcessor.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.document.ReferenceDataType; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.vespa.documentmodel.DocumentSummary; import com.yahoo.vespa.documentmodel.SummaryTransform; @@ -20,11 +20,11 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class ReferenceFieldsProcessor extends Processor { - public ReferenceFieldsProcessor(Search search, + public ReferenceFieldsProcessor(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override @@ -34,7 +34,7 @@ public class ReferenceFieldsProcessor extends Processor { } private void clearSummaryAttributeAspectForExplicitSummaryFields() { - for (DocumentSummary docSum : search.getSummaries().values()) { + for (DocumentSummary docSum : schema.getSummaries().values()) { docSum.getSummaryFields().stream() .filter(summaryField -> summaryField.getDataType() instanceof ReferenceDataType) .forEach(summaryField -> summaryField.setTransform(SummaryTransform.NONE)); @@ -42,7 +42,7 @@ public class ReferenceFieldsProcessor extends Processor { } private void clearSummaryAttributeAspectForConcreteFields() { - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { if (field.getDataType() instanceof ReferenceDataType) { removeFromAttributePrefetchSummaryClass(field); clearSummaryTransformOnSummaryFields(field); @@ -51,14 +51,14 @@ public class ReferenceFieldsProcessor extends Processor { } private void removeFromAttributePrefetchSummaryClass(SDField field) { - DocumentSummary summary = search.getSummary("attributeprefetch"); + DocumentSummary summary = schema.getSummary("attributeprefetch"); if (summary != null) { summary.remove(field.getName()); } } private void clearSummaryTransformOnSummaryFields(SDField field) { - search.getSummaryFields(field).values().forEach(summaryField -> summaryField.setTransform(SummaryTransform.NONE)); + schema.getSummaryFields(field).values().forEach(summaryField -> summaryField.setTransform(SummaryTransform.NONE)); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReservedDocumentNames.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReservedDocumentNames.java index e017726370f..4a39a52a005 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReservedDocumentNames.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReservedDocumentNames.java @@ -3,8 +3,8 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.SDDocumentType; -import com.yahoo.searchdefinition.Search; import com.yahoo.vespa.model.container.search.QueryProfiles; import java.util.HashSet; @@ -23,18 +23,17 @@ public class ReservedDocumentNames extends Processor { } } - public ReservedDocumentNames(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public ReservedDocumentNames(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { if ( ! validate) return; - String docName = search.getDocument().getName(); - if (RESERVED_NAMES.contains(docName)) { - throw new IllegalArgumentException("For search '" + search.getName() + "': Document name '" + docName + - "' is reserved."); - } + String docName = schema.getDocument().getName(); + if (RESERVED_NAMES.contains(docName)) + throw new IllegalArgumentException("For " + schema + ": Document name '" + docName + "' is reserved."); } + } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReservedFunctionNames.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReservedFunctionNames.java index d997422c8f0..8194b9f9e06 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReservedFunctionNames.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReservedFunctionNames.java @@ -5,7 +5,7 @@ import com.google.common.collect.ImmutableSet; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchlib.rankingexpression.parser.RankingExpressionParserConstants; import com.yahoo.vespa.model.container.search.QueryProfiles; @@ -22,8 +22,8 @@ public class ReservedFunctionNames extends Processor { private static Set<String> reservedNames = getReservedNames(); - public ReservedFunctionNames(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public ReservedFunctionNames(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/SearchMustHaveDocument.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/SearchMustHaveDocument.java index b9ecc2e234d..68717f1f06b 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/SearchMustHaveDocument.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/SearchMustHaveDocument.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.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.vespa.model.container.search.QueryProfiles; /** @@ -14,17 +14,17 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class SearchMustHaveDocument extends Processor { - public SearchMustHaveDocument(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public SearchMustHaveDocument(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { if ( ! validate) return; - if (search.getDocument() == null) - throw new IllegalArgumentException("For search '" + search.getName() + - "': A search specification must have an equally named document inside of it."); + if (schema.getDocument() == null) + throw new IllegalArgumentException("For " + schema + + ": A search specification must have an equally named document inside of it."); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/SetRankTypeEmptyOnFilters.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/SetRankTypeEmptyOnFilters.java index eaab175a46e..6631258813a 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/SetRankTypeEmptyOnFilters.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/SetRankTypeEmptyOnFilters.java @@ -3,9 +3,9 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.RankType; import com.yahoo.searchdefinition.document.SDField; -import com.yahoo.searchdefinition.Search; import com.yahoo.vespa.model.container.search.QueryProfiles; /** @@ -15,13 +15,13 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class SetRankTypeEmptyOnFilters extends Processor { - public SetRankTypeEmptyOnFilters(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public SetRankTypeEmptyOnFilters(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { if (field.getRanking().isFilter()) { field.setRankType(RankType.EMPTY); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/SortingSettings.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/SortingSettings.java index f81ff184417..33e9634323b 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/SortingSettings.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/SortingSettings.java @@ -3,10 +3,10 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.document.Sorting; -import com.yahoo.searchdefinition.Search; import com.yahoo.vespa.model.container.search.QueryProfiles; /** @@ -16,23 +16,23 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class SortingSettings extends Processor { - public SortingSettings(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public SortingSettings(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { if ( ! validate) return; - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { for (Attribute attribute : field.getAttributes().values()) { Sorting sorting = attribute.getSorting(); if (sorting.getFunction() != Sorting.Function.UCA) { if (sorting.getStrength()!=null && sorting.getStrength() != Sorting.Strength.PRIMARY) { - warn(search, field, "Sort strength only works for sort function 'uca'."); + warn(schema, field, "Sort strength only works for sort function 'uca'."); } if (sorting.getLocale() != null && ! "".equals(sorting.getLocale())) { - warn(search, field, "Sort locale only works for sort function 'uca'."); + warn(schema, field, "Sort locale only works for sort function 'uca'."); } } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/StringSettingsOnNonStringFields.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/StringSettingsOnNonStringFields.java index ea034665ae1..8c6b07515aa 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/StringSettingsOnNonStringFields.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/StringSettingsOnNonStringFields.java @@ -5,28 +5,28 @@ import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.document.CollectionDataType; import com.yahoo.document.NumericDataType; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.SDField; -import com.yahoo.searchdefinition.Search; import com.yahoo.vespa.model.container.search.QueryProfiles; public class StringSettingsOnNonStringFields extends Processor { - public StringSettingsOnNonStringFields(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public StringSettingsOnNonStringFields(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { if ( ! validate) return; - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { if ( ! doCheck(field)) continue; if (field.getMatching().isTypeUserSet()) { - warn(search, field, "Matching type " + field.getMatching().getType() + + warn(schema, field, "Matching type " + field.getMatching().getType() + " is only allowed for string fields."); } if (field.getRanking().isLiteral()) { - warn(search, field, "Rank type literal only applies to string fields"); + warn(schema, field, "Rank type literal only applies to string fields"); } } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryConsistency.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryConsistency.java index 613674c5c6f..80f9a15f1e5 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryConsistency.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryConsistency.java @@ -5,9 +5,9 @@ import com.yahoo.config.application.api.DeployLogger; import com.yahoo.document.DataType; import com.yahoo.document.TensorDataType; import com.yahoo.searchdefinition.RankProfileRegistry; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.document.WeightedSetDataType; -import com.yahoo.searchdefinition.Search; import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.vespa.documentmodel.DocumentSummary; import com.yahoo.vespa.documentmodel.SummaryField; @@ -24,26 +24,26 @@ import static com.yahoo.searchdefinition.document.ComplexAttributeFieldUtils.isC */ public class SummaryConsistency extends Processor { - public SummaryConsistency(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public SummaryConsistency(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - for (DocumentSummary summary : search.getSummaries().values()) { + for (DocumentSummary summary : schema.getSummaries().values()) { if (summary.getName().equals("default")) continue; for (SummaryField summaryField : summary.getSummaryFields() ) { - assertConsistency(summaryField, search, validate); - makeAttributeTransformIfAppropriate(summaryField, search); - makeAttributeCombinerTransformIfAppropriate(summaryField, search); + assertConsistency(summaryField, schema, validate); + makeAttributeTransformIfAppropriate(summaryField, schema); + makeAttributeCombinerTransformIfAppropriate(summaryField, schema); } } } - private void assertConsistency(SummaryField summaryField, Search search, boolean validate) { + private void assertConsistency(SummaryField summaryField, Schema schema, boolean validate) { // Compare to default: - SummaryField existingDefault = search.getSummary("default").getSummaryField(summaryField.getName()); + SummaryField existingDefault = schema.getSummary("default").getSummaryField(summaryField.getName()); if (existingDefault != null) { if (validate) assertConsistentTypes(existingDefault, summaryField); @@ -51,27 +51,27 @@ public class SummaryConsistency extends Processor { } else { // If no default, compare to whichever definition of the field - SummaryField existing = search.getExplicitSummaryField(summaryField.getName()); + SummaryField existing = schema.getExplicitSummaryField(summaryField.getName()); if (existing == null) return; if (validate) assertConsistentTypes(existing, summaryField); - makeConsistentOrThrow(existing, summaryField, search); + makeConsistentOrThrow(existing, summaryField, schema); } } /** If the source is an attribute, make this use the attribute transform */ - private void makeAttributeTransformIfAppropriate(SummaryField summaryField,Search search) { + private void makeAttributeTransformIfAppropriate(SummaryField summaryField, Schema schema) { if (summaryField.getTransform() != SummaryTransform.NONE) return; - Attribute attribute = search.getAttribute(summaryField.getSingleSource()); + Attribute attribute = schema.getAttribute(summaryField.getSingleSource()); if (attribute == null) return; summaryField.setTransform(SummaryTransform.ATTRIBUTE); } /** If the source is a complex field with only struct field attributes then make this use the attribute combiner transform */ - private void makeAttributeCombinerTransformIfAppropriate(SummaryField summaryField,Search search) { + private void makeAttributeCombinerTransformIfAppropriate(SummaryField summaryField, Schema schema) { if (summaryField.getTransform() == SummaryTransform.NONE) { String source_field_name = summaryField.getSingleSource(); - ImmutableSDField source = search.getField(source_field_name); + ImmutableSDField source = schema.getField(source_field_name); if (source != null && isComplexFieldWithOnlyStructFieldAttributes(source)) { summaryField.setTransform(SummaryTransform.ATTRIBUTECOMBINER); } @@ -94,9 +94,9 @@ public class SummaryConsistency extends Processor { return summaryType.equals(existingType); } - private void makeConsistentOrThrow(SummaryField field1, SummaryField field2, Search search) { + private void makeConsistentOrThrow(SummaryField field1, SummaryField field2, Schema schema) { if (field2.getTransform() == SummaryTransform.ATTRIBUTE && field1.getTransform() == SummaryTransform.NONE) { - Attribute attribute = search.getAttribute(field1.getName()); + Attribute attribute = schema.getAttribute(field1.getName()); if (attribute != null) { field1.setTransform(SummaryTransform.ATTRIBUTE); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryDiskAccessValidator.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryDiskAccessValidator.java index 4ae624d2c35..4bc553b1669 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryDiskAccessValidator.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryDiskAccessValidator.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.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.derived.SummaryClass; import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.vespa.documentmodel.DocumentSummary; @@ -23,11 +23,11 @@ import static com.yahoo.searchdefinition.document.ComplexAttributeFieldUtils.isC */ public class SummaryDiskAccessValidator extends Processor { - public SummaryDiskAccessValidator(Search search, + public SummaryDiskAccessValidator(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @@ -36,12 +36,12 @@ public class SummaryDiskAccessValidator extends Processor { if ( ! validate) return; if (documentsOnly) return; - for (DocumentSummary summary : search.getSummaries().values()) { + for (DocumentSummary summary : schema.getSummaries().values()) { for (SummaryField summaryField : summary.getSummaryFields()) { for (SummaryField.Source source : summaryField.getSources()) { - ImmutableSDField field = search.getField(source.getName()); + ImmutableSDField field = schema.getField(source.getName()); if (field == null) - field = findFieldProducingSummaryField(source.getName(), search).orElse(null); + field = findFieldProducingSummaryField(source.getName(), schema).orElse(null); if (field == null && ! source.getName().equals(SummaryClass.DOCUMENT_ID_FIELD)) throw new IllegalArgumentException(summaryField + " in " + summary + " references " + source + ", but this field does not exist"); @@ -66,8 +66,8 @@ public class SummaryDiskAccessValidator extends Processor { return field.doesAttributing(); } - private Optional<ImmutableSDField> findFieldProducingSummaryField(String name, Search search) { - return search.allFields().filter(field -> field.getSummaryFields().get(name) != null).findAny(); + private Optional<ImmutableSDField> findFieldProducingSummaryField(String name, Schema schema) { + return schema.allFields().filter(field -> field.getSummaryFields().get(name) != null).findAny(); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryDynamicStructsArrays.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryDynamicStructsArrays.java index a9bd57705f8..c350c6800ed 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryDynamicStructsArrays.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryDynamicStructsArrays.java @@ -5,7 +5,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.document.*; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.vespa.documentmodel.SummaryField; import com.yahoo.vespa.documentmodel.SummaryTransform; @@ -21,15 +21,15 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class SummaryDynamicStructsArrays extends Processor { - public SummaryDynamicStructsArrays(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public SummaryDynamicStructsArrays(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { if ( ! validate) return; - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { DataType type = field.getDataType(); if (type instanceof ArrayDataType || type instanceof WeightedSetDataType || type instanceof StructDataType) { for (SummaryField sField : field.getSummaryFields().values()) { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryFieldsMustHaveValidSource.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryFieldsMustHaveValidSource.java index 3ebfa629895..2e2144b819d 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryFieldsMustHaveValidSource.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryFieldsMustHaveValidSource.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.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.derived.SummaryClass; import com.yahoo.vespa.documentmodel.DocumentSummary; import com.yahoo.vespa.documentmodel.SummaryField; @@ -17,15 +17,15 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class SummaryFieldsMustHaveValidSource extends Processor { - SummaryFieldsMustHaveValidSource(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + SummaryFieldsMustHaveValidSource(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { if ( ! validate) return; - for (DocumentSummary summary : search.getSummaries().values()) { + for (DocumentSummary summary : schema.getSummaries().values()) { for (SummaryField summaryField : summary.getSummaryFields()) { if (summaryField.getSources().isEmpty()) { if ((summaryField.getTransform() != SummaryTransform.RANKFEATURES) && @@ -56,7 +56,7 @@ public class SummaryFieldsMustHaveValidSource extends Processor { private void verifySource(String source, SummaryField summaryField, DocumentSummary summary) { if ( ! isValid(source, summaryField, summary) ) { - throw new IllegalArgumentException("For search '" + search.getName() + "', summary class '" + + throw new IllegalArgumentException("For " + schema + ", summary class '" + summary.getName() + "'," + " summary field '" + summaryField.getName() + "': there is no valid source '" + source + "'."); } @@ -71,11 +71,11 @@ public class SummaryFieldsMustHaveValidSource extends Processor { } private boolean isDocumentField(String name) { - return search.getField(name) != null; + return schema.getField(name) != null; } private boolean isSummaryField(String name) { - return search.getSummaryField(name) != null; + return schema.getSummaryField(name) != null; } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryNamesFieldCollisions.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryNamesFieldCollisions.java index b7febdd73b1..1c6f8d54ea3 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryNamesFieldCollisions.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/SummaryNamesFieldCollisions.java @@ -7,7 +7,7 @@ import java.util.Map; import com.yahoo.collections.Pair; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.vespa.documentmodel.DocumentSummary; import com.yahoo.vespa.documentmodel.SummaryField; import com.yahoo.vespa.documentmodel.SummaryField.Source; @@ -21,8 +21,8 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class SummaryNamesFieldCollisions extends Processor { - public SummaryNamesFieldCollisions(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public SummaryNamesFieldCollisions(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override @@ -30,7 +30,7 @@ public class SummaryNamesFieldCollisions extends Processor { if ( ! validate) return; Map<String, Pair<String, String>> fieldToClassAndSource = new HashMap<>(); - for (DocumentSummary summary : search.getSummaries().values()) { + for (DocumentSummary summary : schema.getSummaries().values()) { if ("default".equals(summary.getName())) continue; for (SummaryField summaryField : summary.getSummaryFields() ) { if (summaryField.isImplicit()) continue; @@ -41,12 +41,12 @@ public class SummaryNamesFieldCollisions extends Processor { String prevSource = prevClassAndSource.getSecond(); if ( ! prevClass.equals(summary.getName())) { if ( ! prevSource.equals(source.getName())) { - throw new IllegalArgumentException("For search '"+ search.getName() + - "', summary class '" + summary.getName()+"'," + - " summary field '" + summaryField.getName() + "':" + - " Can not use source '" + source.getName() + + throw new IllegalArgumentException("For " + schema + + ", summary class '" + summary.getName() + "'," + + " summary field '" + summaryField.getName() + "':" + + " Can not use source '" + source.getName() + "' for this summary field, an equally named field in summary class '" + - prevClass + "' uses a different source: '"+prevSource+"'."); + prevClass + "' uses a different source: '" + prevSource + "'."); } } } else { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/TagType.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/TagType.java index 57deb82854a..8cebfc89458 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/TagType.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/TagType.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.document.*; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Matching; import com.yahoo.searchdefinition.document.RankType; import com.yahoo.searchdefinition.document.SDField; @@ -17,16 +17,16 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class TagType extends Processor { - public TagType(Search search, + public TagType(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { if (field.getDataType() instanceof WeightedSetDataType && ((WeightedSetDataType)field.getDataType()).isTag()) implementTagType(field); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/TensorFieldProcessor.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/TensorFieldProcessor.java index 32fefc6d489..a253076f320 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/TensorFieldProcessor.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/TensorFieldProcessor.java @@ -5,7 +5,7 @@ import com.yahoo.config.application.api.DeployLogger; import com.yahoo.document.CollectionDataType; import com.yahoo.document.TensorDataType; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.HnswIndexParams; import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.searchdefinition.document.SDField; @@ -18,13 +18,13 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class TensorFieldProcessor extends Processor { - public TensorFieldProcessor(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public TensorFieldProcessor(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - for (var field : search.allConcreteFields()) { + for (var field : schema.allConcreteFields()) { if ( field.getDataType() instanceof TensorDataType ) { if (validate) { validateIndexingScripsForTensorField(field); @@ -43,8 +43,8 @@ public class TensorFieldProcessor extends Processor { private void validateIndexingScripsForTensorField(SDField field) { if (field.doesIndexing() && !isTensorTypeThatSupportsHnswIndex(field)) { - fail(search, field, "A tensor of type '" + tensorTypeToString(field) + "' does not support having an 'index'. " + - "Currently, only tensors with 1 indexed dimension supports that."); + fail(schema, field, "A tensor of type '" + tensorTypeToString(field) + "' does not support having an 'index'. " + + "Currently, only tensors with 1 indexed dimension supports that."); } } @@ -79,7 +79,7 @@ public class TensorFieldProcessor extends Processor { var attribute = field.getAttributes().get(field.getName()); if (attribute != null && attribute.isFastSearch()) { if (! isTensorTypeThatSupportsDirectStore(field)) { - fail(search, field, "An attribute of type 'tensor' cannot be 'fast-search'."); + fail(schema, field, "An attribute of type 'tensor' cannot be 'fast-search'."); } } } @@ -88,7 +88,7 @@ public class TensorFieldProcessor extends Processor { private void validateHnswIndexParametersRequiresIndexing(SDField field) { var index = field.getIndex(field.getName()); if (index != null && index.getHnswIndexParams().isPresent() && !field.doesIndexing()) { - fail(search, field, "A tensor that specifies hnsw index parameters must also specify 'index' in 'indexing'"); + fail(schema, field, "A tensor that specifies hnsw index parameters must also specify 'index' in 'indexing'"); } } @@ -98,7 +98,7 @@ public class TensorFieldProcessor extends Processor { } if (isTensorTypeThatSupportsHnswIndex(field)) { if (validate && !field.doesAttributing()) { - fail(search, field, "A tensor that has an index must also be an attribute."); + fail(schema, field, "A tensor that has an index must also be an attribute."); } var index = field.getIndex(field.getName()); // TODO: Calculate default params based on tensor dimension size @@ -112,7 +112,7 @@ public class TensorFieldProcessor extends Processor { private void validateDataTypeForCollectionField(SDField field) { if (((CollectionDataType)field.getDataType()).getNestedType() instanceof TensorDataType) - fail(search, field, "A field with collection type of tensor is not supported. Use simple type 'tensor' instead."); + fail(schema, field, "A field with collection type of tensor is not supported. Use simple type 'tensor' instead."); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/TextMatch.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/TextMatch.java index c1c18a552ab..a8065ec4bb5 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/TextMatch.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/TextMatch.java @@ -5,7 +5,7 @@ import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.document.CollectionDataType; import com.yahoo.document.DataType; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Matching; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.document.Stemming; @@ -29,13 +29,13 @@ import java.util.TreeSet; */ public class TextMatch extends Processor { - public TextMatch(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public TextMatch(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { if (field.getMatching().getType() != Matching.Type.TEXT) continue; ScriptExpression script = field.getIndexingScript(); @@ -49,7 +49,7 @@ public class TextMatch extends Processor { Set<String> dynamicSummary = new TreeSet<>(); Set<String> staticSummary = new TreeSet<>(); - new IndexingOutputs(search, deployLogger, rankProfileRegistry, queryProfiles).findSummaryTo(search, + new IndexingOutputs(schema, deployLogger, rankProfileRegistry, queryProfiles).findSummaryTo(schema, field, dynamicSummary, staticSummary); @@ -57,16 +57,16 @@ public class TextMatch extends Processor { visitor.visit(script); if ( ! visitor.requiresTokenize) continue; - ExpressionConverter converter = new MyStringTokenizer(search, findAnnotatorConfig(search, field)); + ExpressionConverter converter = new MyStringTokenizer(schema, findAnnotatorConfig(schema, field)); field.setIndexingScript((ScriptExpression)converter.convert(script)); } } - private AnnotatorConfig findAnnotatorConfig(Search search, SDField field) { + private AnnotatorConfig findAnnotatorConfig(Schema schema, SDField field) { AnnotatorConfig ret = new AnnotatorConfig(); Stemming activeStemming = field.getStemming(); if (activeStemming == null) { - activeStemming = search.getStemming(); + activeStemming = schema.getStemming(); } ret.setStemMode(activeStemming.toStemMode()); ret.setRemoveAccents(field.getNormalizing().doRemoveAccents()); @@ -103,8 +103,8 @@ public class TextMatch extends Processor { final AnnotatorConfig annotatorCfg; - MyStringTokenizer(Search search, AnnotatorConfig annotatorCfg) { - super(TokenizeExpression.class, search); + MyStringTokenizer(Schema schema, AnnotatorConfig annotatorCfg) { + super(TokenizeExpression.class, schema); this.annotatorCfg = annotatorCfg; } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/TypedTransformProvider.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/TypedTransformProvider.java index e309a459a67..d6fdb901ab7 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/TypedTransformProvider.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/TypedTransformProvider.java @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.document.DataType; import com.yahoo.document.Field; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.vespa.indexinglanguage.ValueTransformProvider; import com.yahoo.vespa.indexinglanguage.expressions.*; @@ -13,12 +13,12 @@ import com.yahoo.vespa.indexinglanguage.expressions.*; */ public abstract class TypedTransformProvider extends ValueTransformProvider { - private final Search search; + private final Schema schema; private DataType fieldType; - TypedTransformProvider(Class<? extends Expression> transformClass, Search search) { + TypedTransformProvider(Class<? extends Expression> transformClass, Schema schema) { super(transformClass); - this.search = search; + this.schema = schema; } @Override @@ -26,19 +26,19 @@ public abstract class TypedTransformProvider extends ValueTransformProvider { if (exp instanceof OutputExpression) { String fieldName = ((OutputExpression)exp).getFieldName(); if (exp instanceof AttributeExpression) { - Attribute attribute = search.getAttribute(fieldName); + Attribute attribute = schema.getAttribute(fieldName); if (attribute == null) throw new IllegalArgumentException("Attribute '" + fieldName + "' not found."); fieldType = attribute.getDataType(); } else if (exp instanceof IndexExpression) { - Field field = search.getConcreteField(fieldName); + Field field = schema.getConcreteField(fieldName); if (field == null) throw new IllegalArgumentException("Index field '" + fieldName + "' not found."); fieldType = field.getDataType(); } else if (exp instanceof SummaryExpression) { - Field field = search.getSummaryField(fieldName); + Field field = schema.getSummaryField(fieldName); if (field == null) throw new IllegalArgumentException("Summary field '" + fieldName + "' not found."); fieldType = field.getDataType(); diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/UriHack.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/UriHack.java index 224d7593631..84dc6d369fc 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/UriHack.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/UriHack.java @@ -7,7 +7,7 @@ import com.yahoo.document.CollectionDataType; import com.yahoo.document.DataType; import com.yahoo.document.WeightedSetDataType; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.document.Stemming; import com.yahoo.vespa.model.container.search.QueryProfiles; @@ -23,29 +23,29 @@ public class UriHack extends Processor { private static final List<String> URL_SUFFIX = Arrays.asList("scheme", "host", "port", "path", "query", "fragment", "hostname"); - UriHack(Search search, - DeployLogger deployLogger, - RankProfileRegistry rankProfileRegistry, - QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + UriHack(Schema schema, + DeployLogger deployLogger, + RankProfileRegistry rankProfileRegistry, + QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { if (field.doesIndexing()) { DataType fieldType = field.getDataType(); if (fieldType instanceof CollectionDataType) { fieldType = ((CollectionDataType)fieldType).getNestedType(); } if (fieldType == DataType.URI) { - processField(search, field); + processField(schema, field); } } } } - private void processField(Search search, SDField uriField) { + private void processField(Schema schema, SDField uriField) { String uriName = uriField.getName(); uriField.setStemming(Stemming.NONE); DataType generatedType = DataType.STRING; @@ -69,8 +69,8 @@ public class UriHack extends Processor { if (uriField.getIndex(suffix) != null) { partField.addIndex(uriField.getIndex(suffix)); } - search.addExtraField(partField); - search.fieldSets().addBuiltInFieldSetItem(BuiltInFieldSets.INTERNAL_FIELDSET_NAME, partField.getName()); + schema.addExtraField(partField); + schema.fieldSets().addBuiltInFieldSetItem(BuiltInFieldSets.INTERNAL_FIELDSET_NAME, partField.getName()); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/UrlFieldValidator.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/UrlFieldValidator.java index f059785057b..72f903f8365 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/UrlFieldValidator.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/UrlFieldValidator.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.document.DataType; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.vespa.model.container.search.QueryProfiles; @@ -13,19 +13,19 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class UrlFieldValidator extends Processor { - public UrlFieldValidator(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public UrlFieldValidator(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { if ( ! validate) return; - for (ImmutableSDField field : search.allConcreteFields()) { + for (ImmutableSDField field : schema.allConcreteFields()) { if ( ! field.getDataType().equals(DataType.URI)) continue; if (field.doesAttributing()) - throw new IllegalArgumentException("Error in " + field + " in " + search + ": " + + throw new IllegalArgumentException("Error in " + field + " in " + schema + ": " + "uri type fields cannot be attributes"); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ValidateFieldTypes.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ValidateFieldTypes.java index 923726b7696..0d4bfd09677 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ValidateFieldTypes.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ValidateFieldTypes.java @@ -5,7 +5,7 @@ import com.yahoo.config.application.api.DeployLogger; import com.yahoo.document.DataType; import com.yahoo.document.TensorDataType; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.vespa.documentmodel.DocumentSummary; import com.yahoo.vespa.documentmodel.SummaryField; @@ -23,22 +23,22 @@ import java.util.Map; */ public class ValidateFieldTypes extends Processor { - public ValidateFieldTypes(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public ValidateFieldTypes(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { if (!validate) return; - String searchName = search.getName(); + String searchName = schema.getName(); Map<String, DataType> seenFields = new HashMap<>(); verifySearchAndDocFields(searchName, seenFields); verifySummaryFields(searchName, seenFields); } final protected void verifySearchAndDocFields(String searchName, Map<String, DataType> seenFields) { - search.allFields().forEach(field -> { + schema.allFields().forEach(field -> { checkFieldType(searchName, "index field", field.getName(), field.getDataType(), seenFields); for (Map.Entry<String, Attribute> entry : field.getAttributes().entrySet()) { checkFieldType(searchName, "attribute", entry.getKey(), entry.getValue().getDataType(), seenFields); @@ -47,7 +47,7 @@ public class ValidateFieldTypes extends Processor { } final protected void verifySummaryFields(String searchName, Map<String, DataType> seenFields) { - for (DocumentSummary summary : search.getSummaries().values()) { + for (DocumentSummary summary : schema.getSummaries().values()) { for (SummaryField field : summary.getSummaryFields()) { checkFieldType(searchName, "summary field", field.getName(), field.getDataType(), seenFields); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ValidateFieldTypesDocumentsOnly.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ValidateFieldTypesDocumentsOnly.java index 334e2f8c340..e8b218a80ad 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ValidateFieldTypesDocumentsOnly.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ValidateFieldTypesDocumentsOnly.java @@ -4,22 +4,22 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.document.DataType; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.vespa.model.container.search.QueryProfiles; import java.util.HashMap; import java.util.Map; public class ValidateFieldTypesDocumentsOnly extends ValidateFieldTypes { - public ValidateFieldTypesDocumentsOnly(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public ValidateFieldTypesDocumentsOnly(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override public void process(boolean validate, boolean documentsOnly) { if ( ! validate) return; - String searchName = search.getName(); + String searchName = schema.getName(); Map<String, DataType> seenFields = new HashMap<>(); verifySearchAndDocFields(searchName, seenFields); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ValidateFieldWithIndexSettingsCreatesIndex.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ValidateFieldWithIndexSettingsCreatesIndex.java index 2a14616e5e7..268a9f27b3c 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ValidateFieldWithIndexSettingsCreatesIndex.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ValidateFieldWithIndexSettingsCreatesIndex.java @@ -3,11 +3,10 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.searchdefinition.document.Matching; import com.yahoo.searchdefinition.document.Ranking; import com.yahoo.searchdefinition.document.SDField; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.vespa.model.container.search.QueryProfiles; /** @@ -17,8 +16,8 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class ValidateFieldWithIndexSettingsCreatesIndex extends Processor { - public ValidateFieldWithIndexSettingsCreatesIndex(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public ValidateFieldWithIndexSettingsCreatesIndex(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override @@ -27,15 +26,15 @@ public class ValidateFieldWithIndexSettingsCreatesIndex extends Processor { Matching defaultMatching = new Matching(); Ranking defaultRanking = new Ranking(); - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { if (field.doesIndexing()) continue; if (field.doesAttributing()) continue; if ( ! field.getRanking().equals(defaultRanking)) - fail(search, field, + fail(schema, field, "Fields which are not creating an index or attribute can not contain rank settings."); if ( ! field.getMatching().equals(defaultMatching)) - fail(search, field, + fail(schema, field, "Fields which are not creating an index or attribute can not contain match settings."); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/WordMatch.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/WordMatch.java index 0d8045705b7..c4989604457 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/WordMatch.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/WordMatch.java @@ -6,7 +6,7 @@ import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.document.Matching; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.document.Stemming; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.vespa.model.container.search.QueryProfiles; /** @@ -21,12 +21,12 @@ import com.yahoo.vespa.model.container.search.QueryProfiles; */ public class WordMatch extends Processor { - public WordMatch(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public WordMatch(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } public void process(boolean validate, boolean documentsOnly) { - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { processFieldRecursive(field); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/IndexCommandResolver.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/IndexCommandResolver.java index c9ee6425f97..56926436545 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/IndexCommandResolver.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/IndexCommandResolver.java @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.processing.multifieldresolver; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.document.SDField; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import java.util.ArrayList; import java.util.Arrays; @@ -28,8 +28,8 @@ public class IndexCommandResolver extends MultiFieldResolver { harmonizedCommands.addAll(Arrays.asList(harmonize)); } - public IndexCommandResolver(String indexName, List<SDField> fields, Search search, DeployLogger logger) { - super(indexName, fields, search, logger); + public IndexCommandResolver(String indexName, List<SDField> fields, Schema schema, DeployLogger logger) { + super(indexName, fields, schema, logger); } /** diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/MultiFieldResolver.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/MultiFieldResolver.java index c27fe7d875d..80bb4faeaa5 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/MultiFieldResolver.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/MultiFieldResolver.java @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition.processing.multifieldresolver; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.document.SDField; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import java.util.List; /** @@ -13,14 +13,14 @@ public abstract class MultiFieldResolver { protected String indexName; protected List<SDField> fields; - protected Search search; + protected Schema schema; protected DeployLogger deployLogger; - public MultiFieldResolver(String indexName, List<SDField> fields, Search search, DeployLogger logger) { + public MultiFieldResolver(String indexName, List<SDField> fields, Schema schema, DeployLogger logger) { this.indexName = indexName; this.fields = fields; - this.search = search; + this.schema = schema; this.deployLogger = logger; } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/RankProfileTypeSettingsProcessor.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/RankProfileTypeSettingsProcessor.java index 34f60116aa8..260d76c8ca3 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/RankProfileTypeSettingsProcessor.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/RankProfileTypeSettingsProcessor.java @@ -9,7 +9,7 @@ import com.yahoo.search.query.profile.types.TensorFieldType; import com.yahoo.searchdefinition.FeatureNames; import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.searchdefinition.document.ImportedField; @@ -29,8 +29,8 @@ import java.util.Optional; */ public class RankProfileTypeSettingsProcessor extends Processor { - public RankProfileTypeSettingsProcessor(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); + public RankProfileTypeSettingsProcessor(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + super(schema, deployLogger, rankProfileRegistry, queryProfiles); } @Override @@ -43,8 +43,8 @@ public class RankProfileTypeSettingsProcessor extends Processor { } private void processAttributeFields() { - if (search == null) return; // we're processing global profiles - for (ImmutableSDField field : search.allConcreteFields()) { + if (schema == null) return; // we're processing global profiles + for (ImmutableSDField field : schema.allConcreteFields()) { Attribute attribute = field.getAttributes().get(field.getName()); if (attribute != null && attribute.tensorType().isPresent()) { addAttributeTypeToRankProfiles(attribute.getName(), attribute.tensorType().get().toString()); @@ -53,8 +53,8 @@ public class RankProfileTypeSettingsProcessor extends Processor { } private void processImportedFields() { - if (search == null) return; // we're processing global profiles - Optional<ImportedFields> importedFields = search.importedFields(); + if (schema == null) return; // we're processing global profiles + Optional<ImportedFields> importedFields = schema.importedFields(); if (importedFields.isPresent()) { importedFields.get().fields().forEach((fieldName, field) -> processImportedField(field)); } @@ -69,7 +69,7 @@ public class RankProfileTypeSettingsProcessor extends Processor { } private void addAttributeTypeToRankProfiles(String attributeName, String attributeType) { - for (RankProfile profile : rankProfileRegistry.rankProfilesOf(search)) { + for (RankProfile profile : rankProfileRegistry.rankProfilesOf(schema)) { profile.addAttributeType(attributeName, attributeType); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/RankTypeResolver.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/RankTypeResolver.java index 89acda469b7..231a97f30ec 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/RankTypeResolver.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/RankTypeResolver.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.processing.multifieldresolver; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.document.RankType; import com.yahoo.searchdefinition.document.SDField; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import java.util.List; import java.util.logging.Level; @@ -18,8 +18,8 @@ import java.util.logging.Level; */ public class RankTypeResolver extends MultiFieldResolver { - public RankTypeResolver(String indexName, List<SDField> fields, Search search, DeployLogger logger) { - super(indexName, fields, search, logger); + public RankTypeResolver(String indexName, List<SDField> fields, Schema schema, DeployLogger logger) { + super(indexName, fields, schema, logger); } public void resolve() { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/StemmingResolver.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/StemmingResolver.java index 72942d651d0..1bcf646c8ec 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/StemmingResolver.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/multifieldresolver/StemmingResolver.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.processing.multifieldresolver; import com.yahoo.config.application.api.DeployLogger; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.document.Stemming; @@ -15,8 +15,8 @@ import java.util.logging.Level; */ public class StemmingResolver extends MultiFieldResolver { - public StemmingResolver(String indexName, List<SDField> fields, Search search, DeployLogger logger) { - super(indexName, fields, search, logger); + public StemmingResolver(String indexName, List<SDField> fields, Schema schema, DeployLogger logger) { + super(indexName, fields, schema, logger); } @Override @@ -29,13 +29,13 @@ public class StemmingResolver extends MultiFieldResolver { SDField stemmingField = null; for (SDField field : fields) { if (stemming == null && stemmingField==null) { - stemming = field.getStemming(search); + stemming = field.getStemming(schema); stemmingField = field; - } else if (stemming != field.getStemming(search)) { - deployLogger.logApplicationPackage(Level.WARNING, "Field '" + field.getName() + "' has " + field.getStemming(search) + - ", whereas field '" + stemmingField.getName() + "' has " + stemming + - ". All fields indexing to the index '" + indexName + "' must have the same stemming." + - " This should be corrected as it will make indexing fail in a few cases."); + } else if (stemming != field.getStemming(schema)) { + deployLogger.logApplicationPackage(Level.WARNING, "Field '" + field.getName() + "' has " + field.getStemming(schema) + + ", whereas field '" + stemmingField.getName() + "' has " + stemming + + ". All fields indexing to the index '" + indexName + "' must have the same stemming." + + " This should be corrected as it will make indexing fail in a few cases."); } } } diff --git a/config-model/src/main/java/com/yahoo/vespa/documentmodel/DocumentSummary.java b/config-model/src/main/java/com/yahoo/vespa/documentmodel/DocumentSummary.java index 23c1a48b6fe..967e662dc6b 100644 --- a/config-model/src/main/java/com/yahoo/vespa/documentmodel/DocumentSummary.java +++ b/config-model/src/main/java/com/yahoo/vespa/documentmodel/DocumentSummary.java @@ -2,7 +2,7 @@ package com.yahoo.vespa.documentmodel; import com.yahoo.config.application.api.DeployLogger; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import java.util.ArrayList; import java.util.Collection; @@ -21,10 +21,10 @@ public class DocumentSummary extends FieldView { private boolean omitSummaryFeatures = false; private String inherited; - private final Search owner; + private final Schema owner; /** Creates a DocumentSummary with the given name. */ - public DocumentSummary(String name, Search owner) { + public DocumentSummary(String name, Schema owner) { super(name); this.owner = owner; } @@ -55,13 +55,13 @@ public class DocumentSummary extends FieldView { } public SummaryField getSummaryField(String name) { - var parent = getInherited(); - if (parent != null) { - return parent.getSummaryField(name); - } - return (SummaryField) get(name); + var field = (SummaryField)get(name); + if (field != null) return field; + if (getInherited() == null) return null; + return getInherited().getSummaryField(name); } + // TODO: This does not handle overriding in child summaries correctly public Collection<SummaryField> getSummaryFields() { var fields = new ArrayList<SummaryField>(getFields().size()); var parent = getInherited(); @@ -109,11 +109,6 @@ public class DocumentSummary extends FieldView { return owner.getSummary(inherited); } - /** Returns the name of the summary this was declared to inherit, or null if not sett to inherit anything */ - public String getInheritedName() { - return inherited; - } - @Override public String toString() { return "document summary '" + getName() + "'"; diff --git a/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java b/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java index b5fc0e88540..92e1226ddf6 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java @@ -178,7 +178,7 @@ public final class VespaModel extends AbstractConfigProducerRoot implements Seri version = deployState.getVespaVersion(); fileRegistry = deployState.getFileRegistry(); largeRankExpressions = new LargeRankExpressions(deployState.getFileRegistry()); - rankingConstants = new RankingConstants(deployState.getFileRegistry()); + rankingConstants = new RankingConstants(deployState.getFileRegistry(), Optional.empty()); validationOverrides = deployState.validationOverrides(); applicationPackage = deployState.getApplicationPackage(); provisioned = deployState.provisioned(); @@ -189,7 +189,7 @@ public final class VespaModel extends AbstractConfigProducerRoot implements Seri rankProfileList = new RankProfileList(null, // null search -> global rankingConstants, largeRankExpressions, - new OnnxModels(deployState.getFileRegistry()), + new OnnxModels(deployState.getFileRegistry(), Optional.empty()), AttributeFields.empty, deployState.rankProfileRegistry(), deployState.getQueryProfiles().getRegistry(), @@ -336,7 +336,7 @@ public final class VespaModel extends AbstractConfigProducerRoot implements Seri } private OnnxModels onnxModelInfoFromSource(ImportedMlModel model) { - OnnxModels onnxModels = new OnnxModels(fileRegistry); + OnnxModels onnxModels = new OnnxModels(fileRegistry, Optional.empty()); if (model.modelType().equals(ImportedMlModel.ModelType.ONNX)) { String path = model.source(); String applicationPath = this.applicationPackage.getFileReference(Path.fromString("")).toString(); @@ -350,7 +350,7 @@ public final class VespaModel extends AbstractConfigProducerRoot implements Seri private OnnxModels onnxModelInfoFromStore(String modelName) { String path = ApplicationPackage.MODELS_DIR.append(modelName + ".onnx").toString(); - OnnxModels onnxModels = new OnnxModels(fileRegistry); + OnnxModels onnxModels = new OnnxModels(fileRegistry, Optional.empty()); loadOnnxModelInfo(onnxModels, modelName, path); return onnxModels; } 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 cb9472568e5..43bf8133c74 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 @@ -4,7 +4,7 @@ package com.yahoo.vespa.model.application.validation; import com.yahoo.config.model.deploy.DeployState; import com.yahoo.document.DataType; import com.yahoo.document.PositionDataType; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.ComplexAttributeFieldUtils; import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.vespa.model.VespaModel; @@ -39,18 +39,18 @@ public class ComplexAttributeFieldsValidator extends Validator { } } - private static void validateComplexFields(String clusterName, Search search) { - String unsupportedFields = search.allFields() - .filter(field -> isUnsupportedComplexField(field)) - .map(ComplexAttributeFieldsValidator::toString) - .collect(Collectors.joining(", ")); + private static void validateComplexFields(String clusterName, Schema schema) { + String unsupportedFields = schema.allFields() + .filter(field -> isUnsupportedComplexField(field)) + .map(ComplexAttributeFieldsValidator::toString) + .collect(Collectors.joining(", ")); if (!unsupportedFields.isEmpty()) { throw new IllegalArgumentException( String.format("For cluster '%s', search '%s': The following complex fields do not support using struct field attributes: %s. " + "Only supported for the following complex field types: array or map of struct with primitive types, map of primitive types. " + "The supported primitive types are: byte, int, long, float, double and string", - clusterName, search.getName(), unsupportedFields)); + clusterName, schema.getName(), unsupportedFields)); } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/NoPrefixForIndexes.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/NoPrefixForIndexes.java index c8558b70b6e..67667674ea9 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/NoPrefixForIndexes.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/NoPrefixForIndexes.java @@ -2,10 +2,10 @@ package com.yahoo.vespa.model.application.validation; import com.yahoo.config.model.deploy.DeployState; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.searchdefinition.document.Matching; import com.yahoo.searchdefinition.Index; -import com.yahoo.searchdefinition.Search; import com.yahoo.searchdefinition.derived.DerivedConfiguration; import com.yahoo.vespa.model.VespaModel; import com.yahoo.vespa.model.search.AbstractSearchCluster; @@ -28,16 +28,16 @@ public class NoPrefixForIndexes extends Validator { IndexedSearchCluster sc = (IndexedSearchCluster) cluster; for (DocumentDatabase docDb : sc.getDocumentDbs()) { DerivedConfiguration sdConfig = docDb.getDerivedConfiguration(); - Search search = sdConfig.getSearch(); - for (ImmutableSDField field : search.allConcreteFields()) { + Schema schema = sdConfig.getSearch(); + for (ImmutableSDField field : schema.allConcreteFields()) { if (field.doesIndexing()) { //if (!field.getIndexTo().isEmpty() && !field.getIndexTo().contains(field.getName())) continue; if (field.getMatching().getAlgorithm().equals(Matching.Algorithm.PREFIX)) { - failField(search, field); + failField(schema, field); } for (Map.Entry<String, Index> e : field.getIndices().entrySet()) { if (e.getValue().isPrefix()) { - failField(search, field); + failField(schema, field); } } } @@ -47,8 +47,8 @@ public class NoPrefixForIndexes extends Validator { } } - private void failField(Search search, ImmutableSDField field) { - throw new IllegalArgumentException("For search '" + search.getName() + "', field '" + field.getName() + + private void failField(Schema schema, ImmutableSDField field) { + throw new IllegalArgumentException("For " + schema + ", field '" + field.getName() + "': match/index:prefix is not supported for indexes."); } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RoutingSelectorValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RoutingSelectorValidator.java index 8f9a604f65f..7112c4b9a0a 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RoutingSelectorValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RoutingSelectorValidator.java @@ -10,7 +10,6 @@ import com.yahoo.vespa.model.search.IndexedSearchCluster; /** * Validates routing selector for search and content clusters - * */ public class RoutingSelectorValidator extends Validator { @@ -30,4 +29,5 @@ public class RoutingSelectorValidator extends Validator { } } } + } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/search/IndexingScriptChangeMessageBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/search/IndexingScriptChangeMessageBuilder.java index ba776bb13a1..ce8347b66c1 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/search/IndexingScriptChangeMessageBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/search/IndexingScriptChangeMessageBuilder.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.vespa.model.application.validation.change.search; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.searchdefinition.document.Matching; import com.yahoo.searchdefinition.document.NormalizeLevel; @@ -18,16 +18,16 @@ import com.yahoo.vespa.documentmodel.SummaryTransform; */ public class IndexingScriptChangeMessageBuilder { - private final Search currentSearch; + private final Schema currentSchema; private final ImmutableSDField currentField; - private final Search nextSearch; + private final Schema nextSchema; private final ImmutableSDField nextField; - public IndexingScriptChangeMessageBuilder(Search currentSearch, ImmutableSDField currentField, - Search nextSearch, ImmutableSDField nextField) { - this.currentSearch = currentSearch; + public IndexingScriptChangeMessageBuilder(Schema currentSchema, ImmutableSDField currentField, + Schema nextSchema, ImmutableSDField nextField) { + this.currentSchema = currentSchema; this.currentField = currentField; - this.nextSearch = nextSearch; + this.nextSchema = nextSchema; this.nextField = nextField; } @@ -55,8 +55,8 @@ public class IndexingScriptChangeMessageBuilder { } private void checkStemming(ChangeMessageBuilder builder) { - Stemming currentStemming = currentField.getStemming(currentSearch); - Stemming nextStemming = nextField.getStemming(nextSearch); + Stemming currentStemming = currentField.getStemming(currentSchema); + Stemming nextStemming = nextField.getStemming(nextSchema); if (!currentStemming.equals(nextStemming)) { builder.addChange("stemming", currentStemming.getName(), nextStemming.getName()); } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/search/IndexingScriptChangeValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/search/IndexingScriptChangeValidator.java index 699a63cdd9f..e64a3d44bba 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/search/IndexingScriptChangeValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/search/IndexingScriptChangeValidator.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.model.application.validation.change.search; import com.yahoo.config.application.api.ValidationId; import com.yahoo.config.provision.ClusterSpec; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.vespa.indexinglanguage.ExpressionConverter; import com.yahoo.vespa.indexinglanguage.expressions.Expression; @@ -25,20 +25,20 @@ import java.util.Optional; public class IndexingScriptChangeValidator { private final ClusterSpec.Id id; - private final Search currentSearch; - private final Search nextSearch; + private final Schema currentSchema; + private final Schema nextSchema; - public IndexingScriptChangeValidator(ClusterSpec.Id id, Search currentSearch, Search nextSearch) { + public IndexingScriptChangeValidator(ClusterSpec.Id id, Schema currentSchema, Schema nextSchema) { this.id = id; - this.currentSearch = currentSearch; - this.nextSearch = nextSearch; + this.currentSchema = currentSchema; + this.nextSchema = nextSchema; } public List<VespaConfigChangeAction> validate() { List<VespaConfigChangeAction> result = new ArrayList<>(); - for (ImmutableSDField nextField : new LinkedHashSet<>(nextSearch.allConcreteFields())) { + for (ImmutableSDField nextField : new LinkedHashSet<>(nextSchema.allConcreteFields())) { String fieldName = nextField.getName(); - ImmutableSDField currentField = currentSearch.getConcreteField(fieldName); + ImmutableSDField currentField = currentSchema.getConcreteField(fieldName); if (currentField != null) { validateScripts(currentField, nextField).ifPresent(r -> result.add(r)); } @@ -57,7 +57,7 @@ public class IndexingScriptChangeValidator { ScriptExpression nextScript = nextField.getIndexingScript(); if ( ! equalScripts(currentScript, nextScript)) { ChangeMessageBuilder messageBuilder = new ChangeMessageBuilder(nextField.getName()); - new IndexingScriptChangeMessageBuilder(currentSearch, currentField, nextSearch, nextField).populate(messageBuilder); + new IndexingScriptChangeMessageBuilder(currentSchema, currentField, nextSchema, nextField).populate(messageBuilder); messageBuilder.addChange("indexing script", currentScript.toString(), nextScript.toString()); return Optional.of(VespaReindexAction.of(id, ValidationId.indexingChange, messageBuilder.build())); } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/ml/OnnxModelInfo.java b/config-model/src/main/java/com/yahoo/vespa/model/ml/OnnxModelInfo.java index f0309cc630b..88139de7888 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/ml/OnnxModelInfo.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/ml/OnnxModelInfo.java @@ -107,7 +107,7 @@ public class OnnxModelInfo { unboundSizes.add(size); if (unboundSizes.size() > 1) { throw new IllegalArgumentException("Found conflicting sizes for unbound dimension " + - "for type '" + onnxType + "'"); + "for type '" + onnxType + "'"); } // Handle dimensions with symbolic names @@ -115,7 +115,7 @@ public class OnnxModelInfo { String symbolicName = onnxType.dimensions().get(i).getSymbolicName(); if (symbolicSizes.containsKey(symbolicName) && ! symbolicSizes.get(symbolicName).equals(size)) { throw new IllegalArgumentException("Found conflicting sizes for symbolic dimension '" + - symbolicName + "' for input '" + onnxName + "'"); + symbolicName + "' for input '" + onnxName + "'"); } symbolicSizes.put(symbolicName, size); } @@ -131,7 +131,7 @@ public class OnnxModelInfo { if (app.getFile(generatedModelInfoPath(pathInApplicationPackage)).exists()) { return loadFromGeneratedInfo(pathInApplicationPackage, app); } - throw new IllegalArgumentException("Unable to find ONNX model file or generated ONNX info file"); + throw new IllegalArgumentException("Unable to find ONNX model '" + path + "'"); } static public boolean modelExists(String path, ApplicationPackage app) { 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 28682e92f37..a68993be543 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 @@ -5,7 +5,8 @@ import com.yahoo.config.model.deploy.DeployState; import com.yahoo.config.model.producer.AbstractConfigProducer; import com.yahoo.prelude.fastsearch.DocumentdbInfoConfig; import com.yahoo.search.config.IndexInfoConfig; -import com.yahoo.searchdefinition.DocumentOnlySearch; +import com.yahoo.searchdefinition.DocumentOnlySchema; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.derived.DerivedConfiguration; import com.yahoo.vespa.config.search.AttributesConfig; import com.yahoo.vespa.config.search.DispatchConfig; @@ -195,10 +196,10 @@ public class IndexedSearchCluster extends SearchCluster @Override 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(), - new DerivedConfiguration(search, + Schema schema = spec.getSearchDefinition().getSearch(); + if ( ! (schema instanceof DocumentOnlySchema)) { + DocumentDatabase db = new DocumentDatabase(this, schema.getName(), + new DerivedConfiguration(schema, deployState.getDeployLogger(), deployState.getProperties(), deployState.rankProfileRegistry(), diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/NamedSchema.java b/config-model/src/main/java/com/yahoo/vespa/model/search/NamedSchema.java index 06f8198151f..334493b4a92 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/NamedSchema.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/search/NamedSchema.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.vespa.model.search; -import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.Schema; import java.util.Collection; @@ -11,22 +11,22 @@ import java.util.Collection; // TODO: This class is quite pointless public class NamedSchema { - private final Search search; + private final Schema schema; private final String name; public static final String fileNameSuffix = ".sd"; - public Search getSearch() { - return search; + public Schema getSearch() { + return schema; } public String getName() { return name; } - public NamedSchema(String name, Search search) { + public NamedSchema(String name, Schema schema) { this.name = name; - this.search = search; + this.schema = schema; } //Find search definition from a collection with the name specified 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 8dc711f50f6..a9f9102c11a 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 @@ -4,6 +4,7 @@ package com.yahoo.vespa.model.search; import com.yahoo.config.model.deploy.DeployState; import com.yahoo.config.model.producer.AbstractConfigProducer; import com.yahoo.prelude.fastsearch.DocumentdbInfoConfig; +import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.derived.AttributeFields; import com.yahoo.searchdefinition.derived.DerivedConfiguration; import com.yahoo.vespa.config.search.AttributesConfig; @@ -89,11 +90,11 @@ public class StreamingSearchCluster extends SearchCluster implements throw new IllegalStateException("Logical indexes are not supported: Got " + local.size() + " search definitions, expected 1"); } } - private void deriveSingleSearchDefinition(com.yahoo.searchdefinition.Search localSearch, DeployState deployState) { - if (!localSearch.getName().equals(docTypeName)) { - throw new IllegalStateException("Mismatch between document type name (" + docTypeName + ") and name of search definition (" + localSearch.getName() + ")"); + private void deriveSingleSearchDefinition(Schema localSchema, DeployState deployState) { + if (!localSchema.getName().equals(docTypeName)) { + throw new IllegalStateException("Mismatch between document type name (" + docTypeName + ") and name of search definition (" + localSchema.getName() + ")"); } - this.sdConfig = new DerivedConfiguration(localSearch, deployState.getDeployLogger(), + this.sdConfig = new DerivedConfiguration(localSchema, deployState.getDeployLogger(), deployState.getProperties(), deployState.rankProfileRegistry(), deployState.getQueryProfiles().getRegistry(), |