From cf7c0cb612a2cbc1cd63e7043eae28e5a5ecba06 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Fri, 15 Oct 2021 19:00:17 +0200 Subject: search -> schema --- .../config/model/deploy/SearchDocumentModel.java | 9 +- .../com/yahoo/documentmodel/NewDocumentType.java | 4 +- .../com/yahoo/searchdefinition/Application.java | 8 +- .../yahoo/searchdefinition/DefaultRankProfile.java | 4 +- .../searchdefinition/DocumentModelBuilder.java | 36 +- .../yahoo/searchdefinition/DocumentOnlySchema.java | 29 + .../yahoo/searchdefinition/DocumentOnlySearch.java | 30 - .../yahoo/searchdefinition/DocumentReference.java | 10 +- .../DocumentReferenceResolver.java | 18 +- .../searchdefinition/DocumentsOnlyRankProfile.java | 4 +- .../FieldOperationApplierForSearch.java | 4 +- .../java/com/yahoo/searchdefinition/FieldSets.java | 2 +- .../yahoo/searchdefinition/ImmutableSearch.java | 4 +- .../searchdefinition/ImportedFieldsEnumerator.java | 5 +- .../java/com/yahoo/searchdefinition/Index.java | 4 +- .../com/yahoo/searchdefinition/RankProfile.java | 10 +- .../searchdefinition/RankProfileRegistry.java | 10 +- .../java/com/yahoo/searchdefinition/Schema.java | 705 ++++++++++++++++++++ .../java/com/yahoo/searchdefinition/Search.java | 707 --------------------- .../com/yahoo/searchdefinition/SearchBuilder.java | 102 +-- .../searchdefinition/UnrankedRankProfile.java | 4 +- .../searchdefinition/derived/AttributeFields.java | 10 +- .../yahoo/searchdefinition/derived/Derived.java | 26 +- .../derived/DerivedConfiguration.java | 58 +- .../searchdefinition/derived/ImportedFields.java | 10 +- .../yahoo/searchdefinition/derived/IndexInfo.java | 58 +- .../searchdefinition/derived/IndexSchema.java | 24 +- .../searchdefinition/derived/IndexingScript.java | 24 +- .../yahoo/searchdefinition/derived/Juniperrc.java | 16 +- .../searchdefinition/derived/RankProfileList.java | 24 +- .../searchdefinition/derived/SearchOrderer.java | 52 +- .../yahoo/searchdefinition/derived/Summaries.java | 10 +- .../searchdefinition/derived/SummaryClass.java | 12 +- .../yahoo/searchdefinition/derived/SummaryMap.java | 14 +- .../yahoo/searchdefinition/derived/VsmFields.java | 16 +- .../yahoo/searchdefinition/derived/VsmSummary.java | 24 +- .../validation/IndexStructureValidator.java | 8 +- .../derived/validation/Validation.java | 6 +- .../derived/validation/Validator.java | 8 +- .../document/ImmutableImportedSDField.java | 4 +- .../document/ImmutableSDField.java | 4 +- .../searchdefinition/document/SDDocumentType.java | 18 +- .../yahoo/searchdefinition/document/SDField.java | 6 +- ...ttributeTransformToSummaryOfImportedFields.java | 12 +- .../processing/AddExtraFieldsToDocument.java | 36 +- .../processing/AdjustPositionSummaryFields.java | 18 +- .../processing/AttributeProperties.java | 10 +- .../processing/AttributesImplicitWord.java | 8 +- .../yahoo/searchdefinition/processing/Bolding.java | 8 +- .../processing/BoolAttributeValidator.java | 10 +- .../processing/BuiltInFieldSets.java | 16 +- .../processing/CreatePositionZCurve.java | 22 +- .../processing/DictionaryProcessor.java | 17 +- .../DisallowComplexMapAndWsetKeyTypes.java | 12 +- .../processing/DiversitySettingsValidator.java | 12 +- .../searchdefinition/processing/ExactMatch.java | 28 +- .../processing/FastAccessValidator.java | 18 +- .../processing/FieldSetSettings.java | 42 +- .../processing/FilterFieldNames.java | 18 +- .../processing/ImplicitSummaries.java | 70 +- .../processing/ImplicitSummaryFields.java | 8 +- .../processing/ImportedFieldsResolver.java | 22 +- .../processing/IndexFieldNames.java | 10 +- .../processing/IndexingInputs.java | 22 +- .../processing/IndexingOutputs.java | 36 +- .../processing/IndexingValidation.java | 26 +- .../processing/IndexingValues.java | 10 +- .../processing/IntegerIndex2Attribute.java | 12 +- .../searchdefinition/processing/LiteralBoost.java | 32 +- .../searchdefinition/processing/MakeAliases.java | 14 +- .../processing/MakeDefaultSummaryTheSuperSet.java | 10 +- .../processing/MatchConsistency.java | 22 +- .../processing/MatchPhaseSettingsValidator.java | 12 +- .../processing/MatchedElementsOnlyResolver.java | 18 +- .../processing/MultifieldIndexHarmonizer.java | 28 +- .../processing/MutableAttributes.java | 10 +- .../searchdefinition/processing/NGramMatch.java | 18 +- .../processing/OnnxModelConfigGenerator.java | 16 +- .../processing/OnnxModelTypeResolver.java | 10 +- .../processing/OptimizeIlscript.java | 10 +- .../processing/PagedAttributeValidator.java | 10 +- .../processing/PredicateProcessor.java | 36 +- .../searchdefinition/processing/Processing.java | 12 +- .../searchdefinition/processing/Processor.java | 44 +- .../processing/RankingExpressionTypeResolver.java | 11 +- .../processing/ReferenceFieldsProcessor.java | 14 +- .../processing/ReservedDocumentNames.java | 10 +- .../processing/ReservedFunctionNames.java | 6 +- .../processing/SearchMustHaveDocument.java | 10 +- .../processing/SetRankTypeEmptyOnFilters.java | 8 +- .../processing/SortingSettings.java | 12 +- .../StringSettingsOnNonStringFields.java | 12 +- .../processing/SummaryConsistency.java | 34 +- .../processing/SummaryDiskAccessValidator.java | 16 +- .../processing/SummaryDynamicStructsArrays.java | 8 +- .../SummaryFieldsMustHaveValidSource.java | 14 +- .../processing/SummaryNamesFieldCollisions.java | 18 +- .../yahoo/searchdefinition/processing/TagType.java | 8 +- .../processing/TensorFieldProcessor.java | 20 +- .../searchdefinition/processing/TextMatch.java | 20 +- .../processing/TypedTransformProvider.java | 14 +- .../yahoo/searchdefinition/processing/UriHack.java | 22 +- .../processing/UrlFieldValidator.java | 10 +- .../processing/ValidateFieldTypes.java | 12 +- .../ValidateFieldTypesDocumentsOnly.java | 8 +- ...ValidateFieldWithIndexSettingsCreatesIndex.java | 13 +- .../searchdefinition/processing/WordMatch.java | 8 +- .../multifieldresolver/IndexCommandResolver.java | 6 +- .../multifieldresolver/MultiFieldResolver.java | 8 +- .../RankProfileTypeSettingsProcessor.java | 16 +- .../multifieldresolver/RankTypeResolver.java | 6 +- .../multifieldresolver/StemmingResolver.java | 18 +- .../yahoo/vespa/documentmodel/DocumentSummary.java | 6 +- .../ComplexAttributeFieldsValidator.java | 14 +- .../application/validation/NoPrefixForIndexes.java | 14 +- .../search/IndexingScriptChangeMessageBuilder.java | 18 +- .../search/IndexingScriptChangeValidator.java | 18 +- .../vespa/model/search/IndexedSearchCluster.java | 11 +- .../com/yahoo/vespa/model/search/NamedSchema.java | 12 +- .../vespa/model/search/StreamingSearchCluster.java | 9 +- 120 files changed, 1703 insertions(+), 1707 deletions(-) create mode 100644 config-model/src/main/java/com/yahoo/searchdefinition/DocumentOnlySchema.java delete mode 100644 config-model/src/main/java/com/yahoo/searchdefinition/DocumentOnlySearch.java create mode 100644 config-model/src/main/java/com/yahoo/searchdefinition/Schema.java delete mode 100644 config-model/src/main/java/com/yahoo/searchdefinition/Search.java (limited to 'config-model/src/main/java') 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 names) { List 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 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/documentmodel/NewDocumentType.java b/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentType.java index b9e46989fa3..301141d0465 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; @@ -337,7 +337,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
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 index 5eb28201239..6b9034f35e0 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/Application.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/Application.java @@ -19,7 +19,7 @@ import java.util.Map; public class Application { private final ApplicationPackage applicationPackage; - private final Map schemas = new LinkedHashMap<>(); + private final Map schemas = new LinkedHashMap<>(); public Application(ApplicationPackage applicationPackage) { this.applicationPackage = applicationPackage; @@ -27,17 +27,17 @@ public class Application { public ApplicationPackage applicationPackage() { return applicationPackage; } - public void add(Search schema) { + 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 schemas() { return Collections.unmodifiableMap(schemas); } + public Map schemas() { return Collections.unmodifiableMap(schemas); } /** Used by SearchBuilder, for now */ - void replaceSchemasBy(List schemas) { + void replaceSchemasBy(List schemas) { this.schemas.clear(); for (var schema : schemas) this.schemas.put(schema.getName(), schema); 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..576b23b4dce 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 searchList) { + public void addToModel(Collection schemaList) { List 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 toAdd = tryAdd(searchList); - ! toAdd.isEmpty() && (toAdd.size() < searchList.size()); - toAdd = tryAdd(searchList)) { - searchList = toAdd; + for (Collection 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 tryAdd(Collection searchList) { - Collection left = new ArrayList<>(); - for (Search search : searchList) { + private Collection tryAdd(Collection schemaList) { + Collection 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); diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentOnlySchema.java b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentOnlySchema.java new file mode 100644 index 00000000000..c672b662874 --- /dev/null +++ b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentOnlySchema.java @@ -0,0 +1,29 @@ +// 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.DeployLogger; +import com.yahoo.config.application.api.FileRegistry; +import com.yahoo.config.model.api.ModelContext; +import com.yahoo.searchdefinition.document.SDDocumentType; + +/** + * A search that was derived from an sd file containing no search element(s), only + * document specifications, so the name of this is decided by parsing and adding the document instance. + * + * @author vegardh + */ +public class DocumentOnlySchema extends Schema { + + public DocumentOnlySchema(Application application, FileRegistry fileRegistry, DeployLogger deployLogger, ModelContext.Properties properties) { + super(application, fileRegistry, deployLogger, properties); + } + + @Override + public void addDocument(SDDocumentType docType) { + if (getName() == null) { + setName(docType.getName()); + } + super.addDocument(docType); + } + +} diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentOnlySearch.java b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentOnlySearch.java deleted file mode 100644 index 29d8252f621..00000000000 --- a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentOnlySearch.java +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.searchdefinition; - -import com.yahoo.config.application.api.ApplicationPackage; -import com.yahoo.config.application.api.DeployLogger; -import com.yahoo.config.application.api.FileRegistry; -import com.yahoo.config.model.api.ModelContext; -import com.yahoo.searchdefinition.document.SDDocumentType; - -/** - * A search that was derived from an sd file containing no search element(s), only - * document specifications, so the name of this is decided by parsing and adding the document instance. - * - * @author vegardh - */ -public class DocumentOnlySearch extends Search { - - public DocumentOnlySearch(Application application, FileRegistry fileRegistry, DeployLogger deployLogger, ModelContext.Properties properties) { - super(application, fileRegistry, deployLogger, properties); - } - - @Override - public void addDocument(SDDocumentType docType) { - if (getName() == null) { - setName(docType.getName()); - } - super.addDocument(docType); - } - -} 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 a16433b36dc..26c140e58fe 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentReferenceResolver.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentReferenceResolver.java @@ -23,9 +23,9 @@ import static java.util.stream.Collectors.toMap; */ public class DocumentReferenceResolver { - private final Map searchMapping; + private final Map searchMapping; - public DocumentReferenceResolver(Collection schemas) { + public DocumentReferenceResolver(Collection schemas) { this.searchMapping = createDocumentNameToSearchMapping(schemas); } @@ -63,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) { @@ -77,10 +77,10 @@ public class DocumentReferenceResolver { return sdField.doesAttributing(); } - private static Map createDocumentNameToSearchMapping(Collection searchDefintions) { - return searchDefintions.stream() - .filter(search -> search.getDocument() != null) - .collect(toMap(search -> search.getDocument().getName(), identity())); + private static Map createDocumentNameToSearchMapping(Collection schemaDefintions) { + return schemaDefintions.stream() + .filter(search -> search.getDocument() != null) + .collect(toMap(search -> search.getDocument().getName(), identity())); } private static Stream 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..407d49e65d9 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/FieldSets.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/FieldSets.java @@ -8,7 +8,7 @@ import java.util.Map; 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 diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/ImmutableSearch.java b/config-model/src/main/java/com/yahoo/searchdefinition/ImmutableSearch.java index 605176e0c07..1208707fe96 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/ImmutableSearch.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/ImmutableSearch.java @@ -15,8 +15,8 @@ import java.util.Map; 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 */ 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 91fd0aee957..a1248409368 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/ImportedFieldsEnumerator.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/ImportedFieldsEnumerator.java @@ -4,7 +4,6 @@ package com.yahoo.searchdefinition; import com.yahoo.searchdefinition.document.SDDocumentType; import java.util.Collection; -import java.util.List; /** * Enumerates and emplaces a set of all imported fields into a SDDocumentType from @@ -12,9 +11,9 @@ import java.util.List; */ public class ImportedFieldsEnumerator { - private final Collection schemas; + private final Collection schemas; - public ImportedFieldsEnumerator(Collection schemas) { + public ImportedFieldsEnumerator(Collection 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/RankProfile.java b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java index 68faa462fdd..d48b232cfef 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/RankProfile.java @@ -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(); } /** 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..50ba7d07baa 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,10 +30,10 @@ public class RankProfileRegistry { /* These rank profiles can be overridden: 'default' rank profile, as that is documented to work. And 'unranked'. */ static final Set overridableRankProfileNames = new HashSet<>(Arrays.asList("default", "unranked")); - public static RankProfileRegistry createRankProfileRegistryWithBuiltinRankProfiles(Search search) { + 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; } @@ -69,7 +69,7 @@ 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 search the {@link Schema} that owns the rank profile. * @param name the name of the rank profile * @return the RankProfile to return. */ diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/Schema.java b/config-model/src/main/java/com/yahoo/searchdefinition/Schema.java new file mode 100644 index 00000000000..ea69b829e85 --- /dev/null +++ b/config-model/src/main/java/com/yahoo/searchdefinition/Schema.java @@ -0,0 +1,705 @@ +// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.searchdefinition; + +import com.yahoo.config.application.api.ApplicationPackage; +import com.yahoo.config.application.api.DeployLogger; +import com.yahoo.config.application.api.FileRegistry; +import com.yahoo.config.model.api.ModelContext; +import com.yahoo.config.model.application.provider.BaseDeployLogger; +import com.yahoo.config.model.deploy.TestProperties; +import com.yahoo.document.Field; +import com.yahoo.searchdefinition.derived.SummaryClass; +import com.yahoo.searchdefinition.document.Attribute; +import com.yahoo.searchdefinition.document.ImmutableSDField; +import com.yahoo.searchdefinition.document.ImportedField; +import com.yahoo.searchdefinition.document.ImportedFields; +import com.yahoo.searchdefinition.document.SDDocumentType; +import com.yahoo.searchdefinition.document.SDField; +import com.yahoo.searchdefinition.document.Stemming; +import com.yahoo.searchdefinition.document.TemporaryImportedFields; +import com.yahoo.searchdefinition.document.annotation.SDAnnotationType; +import com.yahoo.vespa.documentmodel.DocumentSummary; +import com.yahoo.vespa.documentmodel.SummaryField; +import com.yahoo.vespa.model.AbstractService; + +import java.io.Reader; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.TreeMap; +import java.util.logging.Level; +import java.util.stream.Stream; + +/** + * 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 Schema implements ImmutableSearch { + + private static final String SD_DOC_FIELD_NAME = "sddocname"; + private static final List 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 schema */ + private String name; + + /** The name of the schema this should inherit all the content of, if any */ + private final Optional inherited; + + /** True if this doesn't define a search, just a document type */ + private final boolean documentsOnly; + + private boolean rawAsBase64 = false; + + /** The stemming setting of this search definition. Default is BEST. */ + private Stemming stemming = Stemming.BEST; + + /** Documents contained in this definition */ + private SDDocumentType docType; + + /** The extra fields of this search definition */ + private final Map fields = new LinkedHashMap<>(); + + /** The explicitly defined indices of this search definition */ + private final Map indices = new LinkedHashMap<>(); + + /** The explicitly defined summaries of this search definition. _Must_ preserve order. */ + private final Map 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 = Optional.of(new TemporaryImportedFields()); + private Optional importedFields = Optional.empty(); + + private final Application application; + private final DeployLogger deployLogger; + private final ModelContext.Properties properties; + + /** Testing only */ + 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 schema + * + * @param name of the schema + * @param inherited the schema this inherits, if any + * @param application the application containing this + */ + public Schema(String name, + Optional inherited, + Application application, + FileRegistry fileRegistry, + DeployLogger deployLogger, + ModelContext.Properties properties) { + this(inherited, application, fileRegistry, deployLogger, properties, false); + this.name = name; + } + + protected Schema(Application application, FileRegistry fileRegistry, DeployLogger deployLogger, ModelContext.Properties properties) { + this(Optional.empty(), application, fileRegistry, deployLogger, properties, true); + } + + private Schema(Optional inherited, + Application application, + FileRegistry fileRegistry, + DeployLogger deployLogger, + ModelContext.Properties properties, + boolean documentsOnly) { + this.inherited = inherited; + this.application = application; + this.deployLogger = deployLogger; + this.properties = properties; + this.documentsOnly = documentsOnly; + largeRankExpressions = new LargeRankExpressions(fileRegistry); + rankingConstants = new RankingConstants(fileRegistry); + onnxModels = new OnnxModels(fileRegistry); + } + + protected void setName(String name) { + this.name = name; + } + + @Override + public String getName() { + return name; + } + + /** + * Returns true if this doesn't define a search, just some documents + * + * @return if the searchdefinition only has documents + */ + public boolean isDocumentsOnly() { + return documentsOnly; + } + + /** + * 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. + * + * @return true if raw shall be encoded as base64 in summary + */ + public boolean isRawAsBase64() { return rawAsBase64; } + + public void enableRawAsBase64() { rawAsBase64 = true; } + + /** + * Sets the stemming default of fields. Default is ALL + * + * @param stemming set default stemming for this searchdefinition + * @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; + } + + /** + * Returns whether fields should be stemmed by default or not. Default is ALL. This is never null. + * + * @return the default stemming for this searchdefinition + */ + public Stemming getStemming() { + return stemming; + } + + /** + * Adds a document type which is defined in this search definition + * + * @param document the document type to add + */ + public void addDocument(SDDocumentType document) { + if (docType != null) { + throw new IllegalArgumentException("Searchdefinition cannot have more than one document"); + } + docType = document; + } + + @Override + public LargeRankExpressions rankExpressionFiles() { return largeRankExpressions; } + + @Override + public RankingConstants rankingConstants() { return rankingConstants; } + + @Override + public OnnxModels onnxModels() { return onnxModels; } + + public void sendTo(Collection services) { + rankingConstants.sendTo(services); + largeRankExpressions.sendTo(services); + onnxModels.sendTo(services); + } + + public Optional temporaryImportedFields() { + return temporaryImportedFields; + } + + public Optional importedFields() { + return importedFields; + } + + public void setImportedFields(ImportedFields importedFields) { + temporaryImportedFields = Optional.empty(); + this.importedFields = Optional.of(importedFields); + } + + @Override + public Stream allImportedFields() { + return importedFields + .map(fields -> fields.fields().values().stream()) + .orElse(Stream.empty()) + .map(field -> field.asImmutableSDField()); + } + + @Override + public ImmutableSDField getField(String name) { + ImmutableSDField field = getConcreteField(name); + if (field != null) return field; + return allImportedFields() + .filter(f -> f.getName().equals(name)) + .findFirst() + .orElse(null); + } + + @Override + public List allFieldsList() { + List all = new ArrayList<>(); + all.addAll(extraFieldList()); + for (Field field : docType.fieldSet()) { + all.add((ImmutableSDField) field); + } + if (importedFields.isPresent()) { + for (ImportedField imported : importedFields.get().fields().values()) { + all.add(imported.asImmutableSDField()); + } + } + return all; + } + + /** + * Gets a document from this search definition + * + * @param name the name of the document to return + * @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; + } + return null; + } + + /** + * @return true if the document has been added. + */ + public boolean hasDocument() { + return docType != null; + } + + /** + * @return The document in this search. + */ + @Override + public SDDocumentType getDocument() { + return docType; + } + + /** + * Returns a list of all the fields of this search definition, that is all fields in all documents, in the documents + * they inherit, and all extra fields. The caller receives ownership to the list - subsequent changes to it will not + * impact this + */ + @Override + public List allConcreteFields() { + List allFields = new ArrayList<>(); + allFields.addAll(extraFieldList()); + for (Field field : docType.fieldSet()) { + allFields.add((SDField)field); + } + return allFields; + } + + /** + * Returns the content of a ranking expression file + */ + @Override + public Reader getRankingExpression(String fileName) { + return application.applicationPackage().getRankingExpression(fileName); + } + + public Application application() { return application; } + + @Override + public ApplicationPackage applicationPackage() { + if (application == null) return null; + return application.applicationPackage(); + } + + @Override + public DeployLogger getDeployLogger() { return deployLogger; } + + @Override + public ModelContext.Properties getDeployProperties() { return properties; } + + /** + * Returns a field defined in this search definition or one if its documents. Fields in this search definition takes + * precedence over document fields having the same name + * + * @param name of the field + * @return the SDField representing the field + */ + @Override + public SDField getConcreteField(String name) { + SDField field = getExtraField(name); + if (field != null) { + return field; + } + return (SDField)docType.getField(name); + } + + /** + * Returns a field defined in one of the documents of this search definition. This does not include the extra + * fields defined outside of a document (those accessible through the getExtraField() method). + * + * @param name The name of the field to return. + * @return The named field, or null if not found. + */ + public SDField getDocumentField(String name) { + return (SDField)docType.getField(name); + } + + /** + * Adds an extra field of this search definition not contained in a document + * + * @param field to add to the schemas list of external fields + */ + public void addExtraField(SDField field) { + if (fields.containsKey(field.getName())) { + deployLogger.logApplicationPackage(Level.WARNING, "Duplicate field " + field.getName() + " in search definition " + getName()); + } else { + field.setIsExtraField(true); + fields.put(field.getName(), field); + } + } + + public Collection extraFieldList() { + return fields.values(); + } + public Collection allExtraFields() { + Map extraFields = new TreeMap<>(); + for (Field field : docType.fieldSet()) { + SDField sdField = (SDField) field; + if (sdField.isExtraField()) { + extraFields.put(sdField.getName(), sdField); + } + } + for (SDField field : extraFieldList()) { + extraFields.put(field.getName(), field); + } + return extraFields.values(); + } + + /** + * Returns a field by name, or null if it is not present + * + * @param fieldName the name of the external field to get + * @return the SDField of this name + */ + public SDField getExtraField(String fieldName) { + return fields.get(fieldName); + } + + /** + * Adds an explicitly defined index to this search definition + * + * @param index the index to add + */ + public void addIndex(Index index) { + indices.put(index.getName(), index); + } + + /** + *

Returns an index, or null if no index with this name has had some explicit settings 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 search or on one of its fields

+ * + * @param name the name of the index to get + * @return the index requested + */ + @Override + public Index getIndex(String name) { + List sameIndices = new ArrayList<>(1); + Index searchIndex = indices.get(name); + if (searchIndex != null) { + sameIndices.add(searchIndex); + } + + 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); + } + return consolidateIndices(sameIndices); + } + + public boolean existsIndex(String name) { + if (indices.get(name) != null) { + return true; + } + for (ImmutableSDField field : allConcreteFields()) { + if (field.existsIndex(name)) { + return true; + } + } + return false; + } + + /** + * Consolidates a set of index settings for the same index into one + * + * @param indices The list of indexes to consolidate. + * @return the consolidated index + */ + private Index consolidateIndices(List indices) { + Index first = indices.get(0); + Index consolidated = new Index(first.getName()); + consolidated.setRankType(first.getRankType()); + consolidated.setType(first.getType()); + for (Index current : indices) { + if (current.isPrefix()) { + consolidated.setPrefix(true); + } + if (current.useInterleavedFeatures()) { + consolidated.setInterleavedFeatures(true); + } + + if (consolidated.getRankType() == null) { + consolidated.setRankType(current.getRankType()); + } else { + if (current.getRankType() != null && + !consolidated.getRankType().equals(current.getRankType())) + { + deployLogger.logApplicationPackage(Level.WARNING, "Conflicting rank type settings for " + + first.getName() + " in " + this + ", using " + + consolidated.getRankType()); + } + } + + for (Iterator j = current.aliasIterator(); j.hasNext();) { + consolidated.addAlias(j.next()); + } + } + 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. + */ + @Override + public List getExplicitIndices() { + List allIndices = new ArrayList<>(indices.values()); + for (ImmutableSDField field : allConcreteFields()) { + for (Index index : field.getIndices().values()) { + allIndices.add(index); + } + } + return Collections.unmodifiableList(allIndices); + } + + /** + * Adds an explicitly defined summary to this search definition + * + * @param summary The summary to add. + */ + public void addSummary(DocumentSummary summary) { + summaries.put(summary.getName(), summary); + } + + /** + *

Returns a summary class defined by this search definition, or null if no summary with this name is defined. + * The default summary, named "default" is always present.

+ * + * @param name the name of the summary to get. + * @return Summary found. + */ + public DocumentSummary getSummary(String name) { + return summaries.get(name); + } + + /** + * Returns the first explicit instance found of a summary field with this name, or null if not present (implicitly + * or explicitly) in any summary class. + * + * @param name The name of the summaryfield to get. + * @return SummaryField to return. + */ + public SummaryField getSummaryField(String name) { + for (DocumentSummary summary : summaries.values()) { + SummaryField summaryField = summary.getSummaryField(name); + if (summaryField != null) { + return summaryField; + } + } + return null; + } + + /** + * 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. + */ + public SummaryField getExplicitSummaryField(String name) { + for (DocumentSummary summary : summaries.values()) { + SummaryField summaryField = summary.getSummaryField(name); + if (summaryField != null && !summaryField.isImplicit()) { + return summaryField; + } + } + return null; + } + + /** + * 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 getSummaries() { + return summaries; + } + + /** + *

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).

The map gets owned by the receiver.

+ * + * @param field The source field. + * @return The map of summary fields found. + */ + @Override + public Map getSummaryFields(ImmutableSDField field) { + Map summaryFields = new java.util.LinkedHashMap<>(); + for (DocumentSummary documentSummary : summaries.values()) { + for (SummaryField summaryField : documentSummary.getSummaryFields()) { + if (summaryField.hasSource(field.getName())) { + summaryFields.put(summaryField.getName(), summaryField); + } + } + } + return summaryFields; + } + + /** + *

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.

The map gets owned by the receiver.

+ * + * @return Map of unique summary fields + */ + public Map getUniqueNamedSummaryFields() { + Map summaryFields = new java.util.LinkedHashMap<>(); + for (DocumentSummary documentSummary : summaries.values()) { + for (SummaryField summaryField : documentSummary.getSummaryFields()) { + summaryFields.put(summaryField.getName(), summaryField); + } + } + return summaryFields; + } + + @Override + public int hashCode() { + return name.hashCode(); + } + + /** + * Returns the first occurrence of an attribute having this name, or null if none + * + * @param name Name of attribute + * @return The Attribute with given name. + */ + public Attribute getAttribute(String name) { + for (ImmutableSDField field : allConcreteFields()) { + Attribute attribute = field.getAttributes().get(name); + if (attribute != null) { + return attribute; + } + } + return null; + } + + @Override + public boolean equals(Object o) { + if (!(o instanceof Schema)) { + return false; + } + + Schema other = (Schema)o; + return getName().equals(other.getName()); + } + + @Override + public String toString() { + return "schema '" + getName() + "'"; + } + + public boolean isAccessingDiskSummary(SummaryField field) { + if (!field.getTransform().isInMemory()) { + return true; + } + if (field.getSources().size() == 0) { + return isAccessingDiskSummary(getName()); + } + for (SummaryField.Source source : field.getSources()) { + if (isAccessingDiskSummary(source.getName())) { + return true; + } + } + return false; + } + + private boolean isAccessingDiskSummary(String source) { + SDField field = getConcreteField(source); + if (field == null) { + return false; + } + if (field.doesSummarying() && !field.doesAttributing()) { + return true; + } + return false; + } + + /** The field set settings for this search */ + public FieldSets fieldSets() { return fieldSets; } + + /** + * For adding structs defined in document scope + * + * @param dt the struct to add + * @return self, for chaining + */ + public Schema addType(SDDocumentType dt) { + docType.addType(dt); // TODO This is a very very dirty thing. It must go + return this; + } + + public Schema addAnnotation(SDAnnotationType dt) { + docType.addAnnotation(dt); + return this; + } + + public void validate(DeployLogger logger) { + for (var summary : summaries.values()) + summary.validate(logger); + } + +} diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/Search.java b/config-model/src/main/java/com/yahoo/searchdefinition/Search.java deleted file mode 100644 index 0b7b1687eb9..00000000000 --- a/config-model/src/main/java/com/yahoo/searchdefinition/Search.java +++ /dev/null @@ -1,707 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.searchdefinition; - -import com.yahoo.config.application.api.ApplicationPackage; -import com.yahoo.config.application.api.DeployLogger; -import com.yahoo.config.application.api.FileRegistry; -import com.yahoo.config.model.api.ModelContext; -import com.yahoo.config.model.application.provider.BaseDeployLogger; -import com.yahoo.config.model.deploy.TestProperties; -import com.yahoo.document.Field; -import com.yahoo.searchdefinition.derived.SummaryClass; -import com.yahoo.searchdefinition.document.Attribute; -import com.yahoo.searchdefinition.document.ImmutableSDField; -import com.yahoo.searchdefinition.document.ImportedField; -import com.yahoo.searchdefinition.document.ImportedFields; -import com.yahoo.searchdefinition.document.SDDocumentType; -import com.yahoo.searchdefinition.document.SDField; -import com.yahoo.searchdefinition.document.Stemming; -import com.yahoo.searchdefinition.document.TemporaryImportedFields; -import com.yahoo.searchdefinition.document.annotation.SDAnnotationType; -import com.yahoo.vespa.documentmodel.DocumentSummary; -import com.yahoo.vespa.documentmodel.SummaryField; -import com.yahoo.vespa.model.AbstractService; - -import java.io.Reader; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -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. - * - * @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 { - - private static final String SD_DOC_FIELD_NAME = "sddocname"; - private static final List 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 schema */ - private String name; - - /** The name of the schema this should inherit all the content of, if any */ - private final Optional inherited; - - /** True if this doesn't define a search, just a document type */ - private final boolean documentsOnly; - - private boolean rawAsBase64 = false; - - /** The stemming setting of this search definition. Default is BEST. */ - private Stemming stemming = Stemming.BEST; - - /** Documents contained in this definition */ - private SDDocumentType docType; - - /** The extra fields of this search definition */ - private final Map fields = new LinkedHashMap<>(); - - /** The explicitly defined indices of this search definition */ - private final Map indices = new LinkedHashMap<>(); - - /** The explicitly defined summaries of this search definition. _Must_ preserve order. */ - private final Map 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 = Optional.of(new TemporaryImportedFields()); - private Optional importedFields = Optional.empty(); - - private final Application application; - private final DeployLogger deployLogger; - private final ModelContext.Properties properties; - - /** Testing only */ - public Search(String name) { - this(name, Optional.empty(), null, null, new BaseDeployLogger(), new TestProperties()); - } - - public Search(String name, - Application application, - FileRegistry fileRegistry, - DeployLogger deployLogger, - ModelContext.Properties properties) { - this(name, Optional.empty(), application, fileRegistry, deployLogger, properties); - } - - /** - * Creates a schema - * - * @param name of the schema - * @param inherited the schema this inherits, if any - * @param application the application containing this - */ - public Search(String name, - Optional inherited, - Application application, - FileRegistry fileRegistry, - DeployLogger deployLogger, - ModelContext.Properties properties) { - this(inherited, application, fileRegistry, deployLogger, properties, false); - this.name = name; - } - - protected Search(Application application, FileRegistry fileRegistry, DeployLogger deployLogger, ModelContext.Properties properties) { - this(Optional.empty(), application, fileRegistry, deployLogger, properties, true); - } - - private Search(Optional inherited, - Application application, - FileRegistry fileRegistry, - DeployLogger deployLogger, - ModelContext.Properties properties, - boolean documentsOnly) { - this.inherited = inherited; - this.application = application; - this.deployLogger = deployLogger; - this.properties = properties; - this.documentsOnly = documentsOnly; - largeRankExpressions = new LargeRankExpressions(fileRegistry); - rankingConstants = new RankingConstants(fileRegistry); - onnxModels = new OnnxModels(fileRegistry); - } - - protected void setName(String name) { - this.name = name; - } - - @Override - public String getName() { - return name; - } - - /** - * Returns true if this doesn't define a search, just some documents - * - * @return if the searchdefinition only has documents - */ - public boolean isDocumentsOnly() { - return documentsOnly; - } - - /** - * 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. - * - * @return true if raw shall be encoded as base64 in summary - */ - public boolean isRawAsBase64() { return rawAsBase64; } - - public void enableRawAsBase64() { rawAsBase64 = true; } - - /** - * Sets the stemming default of fields. Default is ALL - * - * @param stemming set default stemming for this searchdefinition - * @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; - } - - /** - * Returns whether fields should be stemmed by default or not. Default is ALL. This is never null. - * - * @return the default stemming for this searchdefinition - */ - public Stemming getStemming() { - return stemming; - } - - /** - * Adds a document type which is defined in this search definition - * - * @param document the document type to add - */ - public void addDocument(SDDocumentType document) { - if (docType != null) { - throw new IllegalArgumentException("Searchdefinition cannot have more than one document"); - } - docType = document; - } - - @Override - public LargeRankExpressions rankExpressionFiles() { return largeRankExpressions; } - - @Override - public RankingConstants rankingConstants() { return rankingConstants; } - - @Override - public OnnxModels onnxModels() { return onnxModels; } - - public void sendTo(Collection services) { - rankingConstants.sendTo(services); - largeRankExpressions.sendTo(services); - onnxModels.sendTo(services); - } - - public Optional temporaryImportedFields() { - return temporaryImportedFields; - } - - public Optional importedFields() { - return importedFields; - } - - public void setImportedFields(ImportedFields importedFields) { - temporaryImportedFields = Optional.empty(); - this.importedFields = Optional.of(importedFields); - } - - @Override - public Stream allImportedFields() { - return importedFields - .map(fields -> fields.fields().values().stream()) - .orElse(Stream.empty()) - .map(field -> field.asImmutableSDField()); - } - - @Override - public ImmutableSDField getField(String name) { - ImmutableSDField field = getConcreteField(name); - if (field != null) return field; - return allImportedFields() - .filter(f -> f.getName().equals(name)) - .findFirst() - .orElse(null); - } - - @Override - public List allFieldsList() { - List all = new ArrayList<>(); - all.addAll(extraFieldList()); - for (Field field : docType.fieldSet()) { - all.add((ImmutableSDField) field); - } - if (importedFields.isPresent()) { - for (ImportedField imported : importedFields.get().fields().values()) { - all.add(imported.asImmutableSDField()); - } - } - return all; - } - - /** - * Gets a document from this search definition - * - * @param name the name of the document to return - * @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; - } - return null; - } - - /** - * @return true if the document has been added. - */ - public boolean hasDocument() { - return docType != null; - } - - /** - * @return The document in this search. - */ - @Override - public SDDocumentType getDocument() { - return docType; - } - - /** - * Returns a list of all the fields of this search definition, that is all fields in all documents, in the documents - * they inherit, and all extra fields. The caller receives ownership to the list - subsequent changes to it will not - * impact this - */ - @Override - public List allConcreteFields() { - List allFields = new ArrayList<>(); - allFields.addAll(extraFieldList()); - for (Field field : docType.fieldSet()) { - allFields.add((SDField)field); - } - return allFields; - } - - /** - * Returns the content of a ranking expression file - */ - @Override - public Reader getRankingExpression(String fileName) { - return application.applicationPackage().getRankingExpression(fileName); - } - - public Application application() { return application; } - - @Override - public ApplicationPackage applicationPackage() { - if (application == null) return null; - return application.applicationPackage(); - } - - @Override - public DeployLogger getDeployLogger() { return deployLogger; } - - @Override - public ModelContext.Properties getDeployProperties() { return properties; } - - /** - * Returns a field defined in this search definition or one if its documents. Fields in this search definition takes - * precedence over document fields having the same name - * - * @param name of the field - * @return the SDField representing the field - */ - @Override - public SDField getConcreteField(String name) { - SDField field = getExtraField(name); - if (field != null) { - return field; - } - return (SDField)docType.getField(name); - } - - /** - * Returns a field defined in one of the documents of this search definition. This does not include the extra - * fields defined outside of a document (those accessible through the getExtraField() method). - * - * @param name The name of the field to return. - * @return The named field, or null if not found. - */ - public SDField getDocumentField(String name) { - return (SDField)docType.getField(name); - } - - /** - * Adds an extra field of this search definition not contained in a document - * - * @param field to add to the schemas list of external fields - */ - public void addExtraField(SDField field) { - if (fields.containsKey(field.getName())) { - deployLogger.logApplicationPackage(Level.WARNING, "Duplicate field " + field.getName() + " in search definition " + getName()); - } else { - field.setIsExtraField(true); - fields.put(field.getName(), field); - } - } - - public Collection extraFieldList() { - return fields.values(); - } - public Collection allExtraFields() { - Map extraFields = new TreeMap<>(); - for (Field field : docType.fieldSet()) { - SDField sdField = (SDField) field; - if (sdField.isExtraField()) { - extraFields.put(sdField.getName(), sdField); - } - } - for (SDField field : extraFieldList()) { - extraFields.put(field.getName(), field); - } - return extraFields.values(); - } - - /** - * Returns a field by name, or null if it is not present - * - * @param fieldName the name of the external field to get - * @return the SDField of this name - */ - public SDField getExtraField(String fieldName) { - return fields.get(fieldName); - } - - /** - * Adds an explicitly defined index to this search definition - * - * @param index the index to add - */ - public void addIndex(Index index) { - indices.put(index.getName(), index); - } - - /** - *

Returns an index, or null if no index with this name has had some explicit settings 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 search or on one of its fields

- * - * @param name the name of the index to get - * @return the index requested - */ - @Override - public Index getIndex(String name) { - List sameIndices = new ArrayList<>(1); - Index searchIndex = indices.get(name); - if (searchIndex != null) { - sameIndices.add(searchIndex); - } - - 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); - } - return consolidateIndices(sameIndices); - } - - public boolean existsIndex(String name) { - if (indices.get(name) != null) { - return true; - } - for (ImmutableSDField field : allConcreteFields()) { - if (field.existsIndex(name)) { - return true; - } - } - return false; - } - - /** - * Consolidates a set of index settings for the same index into one - * - * @param indices The list of indexes to consolidate. - * @return the consolidated index - */ - private Index consolidateIndices(List indices) { - Index first = indices.get(0); - Index consolidated = new Index(first.getName()); - consolidated.setRankType(first.getRankType()); - consolidated.setType(first.getType()); - for (Index current : indices) { - if (current.isPrefix()) { - consolidated.setPrefix(true); - } - if (current.useInterleavedFeatures()) { - consolidated.setInterleavedFeatures(true); - } - - if (consolidated.getRankType() == null) { - consolidated.setRankType(current.getRankType()); - } else { - if (current.getRankType() != null && - !consolidated.getRankType().equals(current.getRankType())) - { - deployLogger.logApplicationPackage(Level.WARNING, "Conflicting rank type settings for " + - first.getName() + " in " + this + ", using " + - consolidated.getRankType()); - } - } - - for (Iterator j = current.aliasIterator(); j.hasNext();) { - consolidated.addAlias(j.next()); - } - } - 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. - */ - @Override - public List getExplicitIndices() { - List allIndices = new ArrayList<>(indices.values()); - for (ImmutableSDField field : allConcreteFields()) { - for (Index index : field.getIndices().values()) { - allIndices.add(index); - } - } - return Collections.unmodifiableList(allIndices); - } - - /** - * Adds an explicitly defined summary to this search definition - * - * @param summary The summary to add. - */ - public void addSummary(DocumentSummary summary) { - summaries.put(summary.getName(), summary); - } - - /** - *

Returns a summary class defined by this search definition, or null if no summary with this name is defined. - * The default summary, named "default" is always present.

- * - * @param name the name of the summary to get. - * @return Summary found. - */ - public DocumentSummary getSummary(String name) { - return summaries.get(name); - } - - /** - * Returns the first explicit instance found of a summary field with this name, or null if not present (implicitly - * or explicitly) in any summary class. - * - * @param name The name of the summaryfield to get. - * @return SummaryField to return. - */ - public SummaryField getSummaryField(String name) { - for (DocumentSummary summary : summaries.values()) { - SummaryField summaryField = summary.getSummaryField(name); - if (summaryField != null) { - return summaryField; - } - } - return null; - } - - /** - * 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. - */ - public SummaryField getExplicitSummaryField(String name) { - for (DocumentSummary summary : summaries.values()) { - SummaryField summaryField = summary.getSummaryField(name); - if (summaryField != null && !summaryField.isImplicit()) { - return summaryField; - } - } - return null; - } - - /** - * 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 getSummaries() { - return summaries; - } - - /** - *

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).

The map gets owned by the receiver.

- * - * @param field The source field. - * @return The map of summary fields found. - */ - @Override - public Map getSummaryFields(ImmutableSDField field) { - Map summaryFields = new java.util.LinkedHashMap<>(); - for (DocumentSummary documentSummary : summaries.values()) { - for (SummaryField summaryField : documentSummary.getSummaryFields()) { - if (summaryField.hasSource(field.getName())) { - summaryFields.put(summaryField.getName(), summaryField); - } - } - } - return summaryFields; - } - - /** - *

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.

The map gets owned by the receiver.

- * - * @return Map of unique summary fields - */ - public Map getUniqueNamedSummaryFields() { - Map summaryFields = new java.util.LinkedHashMap<>(); - for (DocumentSummary documentSummary : summaries.values()) { - for (SummaryField summaryField : documentSummary.getSummaryFields()) { - summaryFields.put(summaryField.getName(), summaryField); - } - } - return summaryFields; - } - - @Override - public int hashCode() { - return name.hashCode(); - } - - /** - * Returns the first occurrence of an attribute having this name, or null if none - * - * @param name Name of attribute - * @return The Attribute with given name. - */ - public Attribute getAttribute(String name) { - for (ImmutableSDField field : allConcreteFields()) { - Attribute attribute = field.getAttributes().get(name); - if (attribute != null) { - return attribute; - } - } - return null; - } - - @Override - public boolean equals(Object o) { - if (!(o instanceof Search)) { - return false; - } - - Search other = (Search)o; - return getName().equals(other.getName()); - } - - @Override - public String toString() { - return "schema '" + getName() + "'"; - } - - public boolean isAccessingDiskSummary(SummaryField field) { - if (!field.getTransform().isInMemory()) { - return true; - } - if (field.getSources().size() == 0) { - return isAccessingDiskSummary(getName()); - } - for (SummaryField.Source source : field.getSources()) { - if (isAccessingDiskSummary(source.getName())) { - return true; - } - } - return false; - } - - private boolean isAccessingDiskSummary(String source) { - SDField field = getConcreteField(source); - if (field == null) { - return false; - } - if (field.doesSummarying() && !field.doesAttributing()) { - return true; - } - return false; - } - - /** The field set settings for this search */ - public FieldSets fieldSets() { return fieldSets; } - - /** - * For adding structs defined in document scope - * - * @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 - return this; - } - - public Search addAnnotation(SDAnnotationType dt) { - docType.addAnnotation(dt); - return this; - } - - public void validate(DeployLogger logger) { - for (var summary : summaries.values()) - summary.validate(logger); - } - -} 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 adfed2e8147..91ff9040713 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java @@ -37,7 +37,7 @@ import java.util.LinkedList; import java.util.List; /** - * 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. @@ -56,7 +56,7 @@ public class SearchBuilder { /** True to build the document aspect only, skipping instantiation of rank profiles */ private final boolean documentsOnly; - private List searchList = new LinkedList<>(); + private List schemaList = new LinkedList<>(); private boolean isBuilt = false; /** For testing only */ @@ -171,7 +171,7 @@ public class SearchBuilder { SimpleCharStream stream = new SimpleCharStream(str); try { return importRawSearch(new SDParser(stream, fileRegistry, deployLogger, properties, application, rankProfileRegistry, documentsOnly) - .search(docTypeMgr, searchDefDir)); + .schema(docTypeMgr, searchDefDir)); } catch (TokenMgrException e) { throw new ParseException("Unknown symbol: " + e.getMessage()); } catch (ParseException pe) { @@ -181,19 +181,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 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 schema) { + public String importRawSearch(Schema schema) { if (schema.getName() == null) throw new IllegalArgumentException("Schema has no name"); String rawName = schema.getName(); application.add(schema); - searchList.add(schema); + schemaList.add(schema); return rawName; } @@ -221,12 +221,12 @@ public class SearchBuilder { if (validate) application.validate(deployLogger); - List built = new ArrayList<>(); + List built = new ArrayList<>(); List 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()); } } @@ -237,46 +237,46 @@ 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; } /** - * 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, rankProfileRegistry, queryProfiles, validate, documentsOnly); } /** - * 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 (application.schemas().size() != 1) throw new IllegalStateException("This call only works if we have 1 schema. Schemas: " + @@ -290,7 +290,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, @@ -298,23 +298,23 @@ 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(); return application.schemas().get(name); } /** - * 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 */ - public List getSearchList() { - return new ArrayList<>(searchList); + public List 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. @@ -340,7 +340,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 @@ -367,7 +367,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. @@ -456,27 +456,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 { @@ -484,16 +484,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) @@ -502,32 +502,32 @@ 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() { 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 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 commands = new java.util.LinkedHashSet<>(); private final Map aliases = new java.util.LinkedHashMap<>(); private final Map 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 collections = new LinkedHashMap<>(); private final Map 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 expressions = new ArrayList<>(); private List 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 fieldsSettingLanguage(Search search) { - return search.allFieldsList().stream() - .filter(field -> ! field.isImportedField()) - .filter(field -> field.containsExpression(SetLanguageExpression.class)) - .collect(Collectors.toList()); + private List fieldsSettingLanguage(Schema schema) { + return schema.allFieldsList().stream() + .filter(field -> ! field.isImportedField()) + .filter(field -> field.containsExpression(SetLanguageExpression.class)) + .collect(Collectors.toList()); } public Iterable 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..9f043770eab 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; @@ -53,10 +53,10 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ /** * Creates a rank profile * - * @param search the search definition this is a rank profile from + * @param schema the search definition 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 +66,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 +82,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 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 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 ready, QueryProfileRegistry queryProfiles, ImportedMlModels importedModels, - Search search, + Schema schema, AttributeFields attributeFields, ModelContext.Properties deployProperties, ExecutorService executor) { Map> 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 documentNameToSearch = new HashMap<>(); + private final Map 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 order(List unordered) { + public List order(List 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 ordered = new ArrayList<>(unordered.size()); - List moveOutwards = new ArrayList<>(); - for (Search search : unordered) { - if (allDependenciesAlreadyEmitted(ordered, search)) { - addOrdered(ordered, search, moveOutwards); + List ordered = new ArrayList<>(unordered.size()); + List 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 ordered, Search search, List moveOutwards) { - ordered.add(search); - Search eligibleMove; + private void addOrdered(List ordered, Schema schema, List 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 moveOutwards, List ordered) { - for (Search move : moveOutwards) { + private Schema removeFirstEntryWithFullyEmittedDependencies(List moveOutwards, List 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 alreadyOrdered, Search search) { - if (search.getDocument() == null) { + private boolean allDependenciesAlreadyEmitted(List 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 alreadyOrdered, SDDocumentType document) { + private boolean allInheritedDependenciesEmitted(List 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 alreadyOrdered, SDDocumentType document) { + private static boolean allReferenceDependenciesEmitted(List 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 searches) { + private void indexOnDocumentName(List 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 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 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 fields=new LinkedHashMap<>(); private final Map 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> 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 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/SDDocumentType.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/SDDocumentType.java index 5d50abec8bb..cef9cf3dede 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; @@ -149,13 +149,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 +196,10 @@ public class SDDocumentType implements Cloneable, Serializable { public Collection getInheritedTypes() { return inheritedTypes.values(); } - protected void validateId(Search search) { - if (search == null) return; - if (search.getDocument(getName()) == null) return; - SDDocumentType doc = search.getDocument(); + 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() + "'"); } @@ -312,7 +312,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/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 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..d7e68dc7dab 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,14 @@ 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,21 +32,21 @@ 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 (Field field : schema.extraFieldList()) { + addSdField(schema, document, (SDField)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; } @@ -57,19 +57,19 @@ public class AddExtraFieldsToDocument extends Processor { 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) { + private void addField(Schema schema, SDDocumentType document, Field field, boolean validate) { if (document.getField(field.getName()) != null) { 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 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 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..5605f66cd69 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,25 +16,25 @@ 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(), + schema.getName(), invalidAttributes)); } } 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..0598bb70afd 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 search '" + schema.getName() + + "': 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 filterFields = new LinkedHashSet<>(); - findFilterFields(search, profile, filterFields); + findFilterFields(schema, profile, filterFields); for (Iterator 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 filterFields) { + private void findFilterFields(Schema schema, RankProfile profile, Set filterFields) { for (Iterator 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..7875bd6f4d5 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.getSummaries().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); 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..ed04303a3ba 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; @@ -35,15 +35,15 @@ public class ImportedFieldsResolver extends Processor { private final Map importedFields = new LinkedHashMap<>(); private final Optional 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,14 @@ 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 search '" + schema.getName() + "', 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 search '" + schema.getName() + "', 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 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 dynamicSummary, Set staticSummary) { - Map summaryFields = search.getSummaryFields(field); + public void findSummaryTo(Schema schema, SDField field, Set dynamicSummary, Set staticSummary) { + Map 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 summaryFields, - Set dynamicSummary, Set staticSummary) { + private void fillSummaryToFromSearch(Schema schema, SDField field, Map summaryFields, + Set dynamicSummary, Set 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 dynamicSummary, Set 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 summaryFields; final boolean validate; - MyConverter(Search search, Field field, Set summaryFields, boolean validate) { - this.search = search; + MyConverter(Schema schema, Field field, Set 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 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..48712b3bb35 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 usedAliases = new ArrayList<>(); - for (SDField field : search.allConcreteFields()) { + for (SDField field : schema.allConcreteFields()) { for (Map.Entry 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 search '" + schema.getName() + "': 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 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 types, String indexTo) { + private void checkMatching(Schema schema, SDField field, Map 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 types; - MyVisitor(Search search, SDField field, Map types) { - this.search = search; + MyVisitor(Schema schema, SDField field, Map 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..7e78b76eb7f 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 search '" + schema.getName() + "', 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> 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> entry : indexToFields.entrySet()) { String indexName = entry.getKey(); List 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 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 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..fb60dfd283d 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,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.processing.multifieldresolver.RankProfileTypeSettingsProcessor; import com.yahoo.vespa.model.container.search.QueryProfiles; @@ -94,19 +94,19 @@ public class Processing { } /** - * Runs all search processors on the given {@link Search} object. These will modify the search object, possibly + * Runs all search processors on the given {@link Schema} object. These will modify the search object, possibly * exchanging it with another, as well as its document types. * - * @param search The search to process. + * @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. */ - public void process(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, + public void process(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles, boolean validate, boolean documentsOnly) { Collection factories = processors(); factories.stream() - .map(factory -> factory.create(search, deployLogger, rankProfileRegistry, queryProfiles)) + .map(factory -> factory.create(schema, deployLogger, rankProfileRegistry, queryProfiles)) .forEach(processor -> processor.process(validate, documentsOnly)); } @@ -127,7 +127,7 @@ 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..2b18ee27f73 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 matchingRankSettingsIterator( - Search search, RankProfile.RankSetting.Type type) + Schema schema, RankProfile.RankSetting.Type type) { List 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)) { @@ -120,12 +120,12 @@ public abstract class Processor { return new IllegalArgumentException(formatError(searchName, 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) { @@ -133,8 +133,8 @@ public abstract class Processor { 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) { @@ -142,8 +142,8 @@ public abstract class Processor { 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 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..549f53d6d8d 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,17 +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(); + String docName = schema.getDocument().getName(); if (RESERVED_NAMES.contains(docName)) { - throw new IllegalArgumentException("For search '" + search.getName() + "': Document name '" + docName + + throw new IllegalArgumentException("For search '" + schema.getName() + "': 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 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..a48c410fe11 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,16 +14,16 @@ 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() + + if (schema.getDocument() == null) + throw new IllegalArgumentException("For search '" + schema.getName() + "': 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 findFieldProducingSummaryField(String name, Search search) { - return search.allFields().filter(field -> field.getSummaryFields().get(name) != null).findAny(); + private Optional 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..6d55a52f959 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 search '" + schema.getName() + "', 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..6a51cd649b6 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> 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 search '" + schema.getName() + + "', 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 dynamicSummary = new TreeSet<>(); Set 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 transformClass, Search search) { + TypedTransformProvider(Class 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 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 seenFields = new HashMap<>(); verifySearchAndDocFields(searchName, seenFields); verifySummaryFields(searchName, seenFields); } final protected void verifySearchAndDocFields(String searchName, Map seenFields) { - search.allFields().forEach(field -> { + schema.allFields().forEach(field -> { checkFieldType(searchName, "index field", field.getName(), field.getDataType(), seenFields); for (Map.Entry 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 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 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 fields, Search search, DeployLogger logger) { - super(indexName, fields, search, logger); + public IndexCommandResolver(String indexName, List 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 fields; - protected Search search; + protected Schema schema; protected DeployLogger deployLogger; - public MultiFieldResolver(String indexName, List fields, Search search, DeployLogger logger) { + public MultiFieldResolver(String indexName, List 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 = search.importedFields(); + if (schema == null) return; // we're processing global profiles + Optional 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 fields, Search search, DeployLogger logger) { - super(indexName, fields, search, logger); + public RankTypeResolver(String indexName, List 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 fields, Search search, DeployLogger logger) { - super(indexName, fields, search, logger); + public StemmingResolver(String indexName, List 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 67e26a899bd..e0f0178cee3 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; } 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..25085683ca6 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 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 search '" + schema.getName() + "', 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/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 validate() { List 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/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 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(), -- cgit v1.2.3