diff options
Diffstat (limited to 'config-model/src/main/java/com')
24 files changed, 133 insertions, 133 deletions
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 cbbcee0dcfa..16a0454cb4b 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/DefaultRankProfile.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/DefaultRankProfile.java @@ -1,9 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.searchdefinition; -import com.yahoo.searchdefinition.document.SDField; +import com.yahoo.searchdefinition.document.ImmutableSDField; -import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Set; @@ -41,7 +40,7 @@ public class DefaultRankProfile extends RankProfile { RankSetting setting = super.getRankSetting(fieldOrIndex,type); if (setting != null) return setting; - SDField field = getSearch().getConcreteField(fieldOrIndex); + ImmutableSDField field = getSearch().getConcreteField(fieldOrIndex); if (field != null) { setting = toRankSetting(field,type); if (setting != null) @@ -58,7 +57,7 @@ public class DefaultRankProfile extends RankProfile { return null; } - private RankSetting toRankSetting(SDField field,RankSetting.Type type) { + private RankSetting toRankSetting(ImmutableSDField field,RankSetting.Type type) { if (type.equals(RankSetting.Type.WEIGHT) && field.getWeight()>0 && field.getWeight()!=100) return new RankSetting(field.getName(),type,field.getWeight()); if (type.equals(RankSetting.Type.RANKTYPE)) @@ -90,7 +89,7 @@ public class DefaultRankProfile extends RankProfile { public Set<RankSetting> rankSettings() { Set<RankSetting> settings = new LinkedHashSet<>(20); settings.addAll(this.rankSettings); - for (SDField field : getSearch().allConcreteFields() ) { + for (ImmutableSDField field : getSearch().allConcreteFields() ) { addSetting(field, RankSetting.Type.WEIGHT, settings); addSetting(field, RankSetting.Type.RANKTYPE, settings); addSetting(field, RankSetting.Type.LITERALBOOST, settings); @@ -104,7 +103,7 @@ public class DefaultRankProfile extends RankProfile { return settings; } - private void addSetting(SDField field, RankSetting.Type type, Set<RankSetting> settings) { + private void addSetting(ImmutableSDField field, RankSetting.Type type, Set<RankSetting> settings) { if (type.isIndexLevel()) { addIndexSettings(field, type, settings); } @@ -115,14 +114,12 @@ public class DefaultRankProfile extends RankProfile { } } - private void addIndexSettings(SDField field, RankSetting.Type type, Set<RankSetting> settings) { - for (Iterator i = field.getFieldNameAsIterator(); i.hasNext(); ) { - String indexName = (String)i.next(); + private void addIndexSettings(ImmutableSDField field, RankSetting.Type type, Set<RankSetting> settings) { + String indexName = field.getName(); - // TODO: Make a ranking object in the index override the field level ranking object - if (type.equals(RankSetting.Type.PREFERBITVECTOR) && field.getRanking().isFilter()) { - settings.add(new RankSetting(indexName, type, true)); - } + // TODO: Make a ranking object in the index override the field level ranking object + if (type.equals(RankSetting.Type.PREFERBITVECTOR) && field.getRanking().isFilter()) { + settings.add(new RankSetting(indexName, type, true)); } } 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 813be5ef0da..0b9447d05f5 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/ImmutableSearch.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/ImmutableSearch.java @@ -21,7 +21,8 @@ public interface ImmutableSearch { String getName(); Index getIndex(String name); - SDField getConcreteField(String name); + ImmutableSDField getConcreteField(String name); + //TODO split in mutating/immutable by returning List<ImmutableSDField> List<SDField> allConcreteFields(); List<Index> getExplicitIndices(); Reader getRankingExpression(String fileName); diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/Search.java b/config-model/src/main/java/com/yahoo/searchdefinition/Search.java index 5a373cfc55f..f90a7e4f6cd 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/Search.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/Search.java @@ -17,7 +17,6 @@ import com.yahoo.vespa.documentmodel.DocumentSummary; import com.yahoo.vespa.documentmodel.SummaryField; import java.io.Reader; -import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -353,7 +352,7 @@ public class Search implements ImmutableSearch { sameIndices.add(searchIndex); } - for (SDField field : allConcreteFields()) { + for (ImmutableSDField field : allConcreteFields()) { Index index = field.getIndex(name); if (index != null) { sameIndices.add(index); @@ -372,7 +371,7 @@ public class Search implements ImmutableSearch { if (indices.get(name) != null) { return true; } - for (SDField field : allConcreteFields()) { + for (ImmutableSDField field : allConcreteFields()) { if (field.existsIndex(name)) { return true; } @@ -423,7 +422,7 @@ public class Search implements ImmutableSearch { @Override public List<Index> getExplicitIndices() { List<Index> allIndices = new ArrayList<>(indices.values()); - for (SDField field : allConcreteFields()) { + for (ImmutableSDField field : allConcreteFields()) { for (Index index : field.getIndices().values()) { allIndices.add(index); } @@ -546,7 +545,7 @@ public class Search implements ImmutableSearch { * @return The Attribute with given name. */ public Attribute getAttribute(String name) { - for (SDField field : allConcreteFields()) { + for (ImmutableSDField field : allConcreteFields()) { Attribute attribute = field.getAttributes().get(name); if (attribute != null) { return attribute; 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 be5f135f819..9c183d99435 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 @@ -24,7 +24,7 @@ public class ImmutableImportedSDField implements ImmutableSDField { private final ImportedField importedField; - public ImmutableImportedSDField(ImportedField importedField) { + ImmutableImportedSDField(ImportedField importedField) { this.importedField = importedField; } @@ -63,14 +63,16 @@ public class ImmutableImportedSDField implements ImmutableSDField { } @Override - public ImmutableSDField getBackingField() { return importedField.targetField(); } - - @Override public boolean isIndexStructureField() { return importedField.targetField().isIndexStructureField(); } @Override + public boolean hasIndex() { + return importedField.targetField().hasIndex(); + } + + @Override public boolean usesStructOrMap() { return importedField.targetField().usesStructOrMap(); } @@ -81,6 +83,11 @@ public class ImmutableImportedSDField implements ImmutableSDField { } @Override + public SummaryField getSummaryField(String name) { + return importedField.targetField().getSummaryField(name); + } + + @Override public Index getIndex(String name) { if ( ! importedField.fieldName().equals(name)) { throw new IllegalArgumentException("Getting an index (" + name + ") with different name than the imported field (" @@ -158,6 +165,31 @@ public class ImmutableImportedSDField implements ImmutableSDField { return importedField.fieldName(); // Name of the imported field, not the target field } + @Override + public int getWeight() { + return importedField.targetField().getWeight(); + } + + @Override + public int getLiteralBoost() { + return importedField.targetField().getLiteralBoost(); + } + + @Override + public RankType getRankType() { + return importedField.targetField().getRankType(); + } + + @Override + public Map<String, Index> getIndices() { + return importedField.targetField().getIndices(); + } + + @Override + public boolean existsIndex(String name) { + return importedField.targetField().existsIndex(name); + } + /** * Returns a field representation of the imported field. * Changes to the returned instance are not propagated back to the underlying imported field! 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 15e75ad8314..7f92e676118 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 @@ -33,16 +33,6 @@ public interface ImmutableSDField { boolean isImportedField(); - /** - * Returns the field backing this - the field itself if this is a regular field, - * and the target field if this is imported. - */ - ImmutableSDField getBackingField(); - - default boolean isConcreteField() { - return !isImportedField(); - } - boolean isIndexStructureField(); boolean usesStructOrMap(); @@ -83,4 +73,11 @@ public interface ImmutableSDField { Field asField(); boolean hasFullIndexingDocprocRights(); + int getWeight(); + int getLiteralBoost(); + RankType getRankType(); + Map<String, Index> getIndices(); + boolean existsIndex(String name); + SummaryField getSummaryField(String name); + boolean hasIndex(); } 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 93b3ff29e13..e9e168edea3 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 @@ -220,9 +220,6 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer, } @Override - public ImmutableSDField getBackingField() { return this; } - - @Override public boolean doesAttributing() { return containsExpression(AttributeExpression.class); } @@ -521,12 +518,9 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer, return Collections.singletonList(getName()).iterator(); } - /** Returns 1 if this is indexed, 0 if it is not indexed */ // TODO: Replace by a boolean method, or something, see hasIndex - public int getIndexToCount() { - if (getIndexingScript() == null) return 0; - if (!doesIndexing()) return 0; - - return 1; + @Override + public boolean hasIndex() { + return (getIndexingScript() != null) && doesIndexing(); } /** Sets the literal boost of this field */ @@ -537,12 +531,14 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer, * when a query term matched as query term exactly (unnormalized and unstemmed). * Default is non-positive. */ + @Override public int getLiteralBoost() { return literalBoost; } /** Sets the weight of this field */ public void setWeight(int weight) { this.weight=weight; } /** Returns the weight of this field, or 0 if nothing is set */ + @Override public int getWeight() { return weight; } /** @@ -600,6 +596,7 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer, * Returns an index if this field has one (implicitly or * explicitly) targeting the given name. */ + @Override public boolean existsIndex(String name) { if (indices.get(name) != null) return true; if (name.equals(getName())) { @@ -614,6 +611,7 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer, * Defined indices on this field * @return defined indices on this */ + @Override public Map<String, Index> getIndices() { return indices; } @@ -638,6 +636,7 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer, public Ranking getRanking() { return ranking; } /** Returns the default rank type of indices of this field, or null if nothing is set */ + @Override public RankType getRankType() { return this.rankType; } /** @@ -712,6 +711,7 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer, * Returns a summary field defined (implicitly or explicitly) by this field. * Returns null if there is no such summary field defined. */ + @Override public SummaryField getSummaryField(String name) { return summaryFields.get(name); } 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 e75547a5bb2..d1eb18c4916 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 @@ -47,7 +47,7 @@ public class AddExtraFieldsToDocument extends Processor { } private void addSdField(Search search, SDDocumentType document, SDField field, boolean validate) { - if (field.getIndexToCount() == 0 && field.getAttributes().isEmpty()) { + if (! field.hasIndex() && field.getAttributes().isEmpty()) { return; } for (Attribute atr : field.getAttributes().values()) { 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 94589d94255..5bcb2ddf54f 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 @@ -4,6 +4,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.searchdefinition.RankProfileRegistry; 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; @@ -21,7 +22,7 @@ public class AttributeProperties extends Processor { @Override public void process(boolean validate, boolean documentsOnly) { - for (SDField field : search.allConcreteFields()) { + for (ImmutableSDField field : search.allConcreteFields()) { String fieldName = field.getName(); // For each attribute, check if the attribute has been created @@ -56,7 +57,7 @@ public class AttributeProperties extends Processor { * @param attributeName name of the attribute * @return true if the attribute has been created by this field, else false */ - static boolean attributeCreated(SDField field, String attributeName) { + static boolean attributeCreated(ImmutableSDField field, String attributeName) { if ( ! field.doesAttributing()) { return false; } 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 23257e5eafd..55f101a4877 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,9 +4,9 @@ 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.document.ImmutableSDField; import com.yahoo.searchdefinition.document.Matching; import com.yahoo.document.NumericDataType; -import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.Search; import com.yahoo.vespa.model.container.search.QueryProfiles; @@ -24,20 +24,20 @@ public class AttributesImplicitWord extends Processor { @Override public void process(boolean validate, boolean documentsOnly) { - for (SDField field : search.allConcreteFields()) { + for (ImmutableSDField field : search.allConcreteFields()) { if (fieldImplicitlyWordMatch(field)) { field.getMatching().setType(Matching.Type.WORD); } } } - private boolean fieldImplicitlyWordMatch(SDField field) { + private boolean fieldImplicitlyWordMatch(ImmutableSDField field) { // numeric types should not trigger exact-match query parsing DataType dt = field.getDataType().getPrimitiveType(); if (dt != null && dt instanceof NumericDataType) { return false; } - return (field.getIndexToCount() == 0 + return (! field.hasIndex() && !field.getAttributes().isEmpty() && field.getIndices().isEmpty() && !field.getMatching().isTypeUserSet()); 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 b59d3527e87..86a272d5201 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 @@ -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.document.SDField; +import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.searchdefinition.Search; import com.yahoo.vespa.documentmodel.SummaryField; import com.yahoo.vespa.model.container.search.QueryProfiles; @@ -24,7 +24,7 @@ public class Bolding extends Processor { @Override public void process(boolean validate, boolean documentsOnly) { if ( ! validate) return; - for (SDField field : search.allConcreteFields()) { + for (ImmutableSDField field : search.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/DisallowComplexMapAndWsetKeyTypes.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/DisallowComplexMapAndWsetKeyTypes.java index 1994b1096ce..267ff827e77 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 @@ -3,6 +3,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.document.ArrayDataType; +import com.yahoo.document.Field; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.document.DataType; import com.yahoo.document.MapDataType; @@ -34,7 +35,7 @@ public class DisallowComplexMapAndWsetKeyTypes extends Processor { } } - private void checkFieldType(SDField field, DataType dataType) { + private void checkFieldType(Field field, DataType dataType) { if (dataType instanceof ArrayDataType) { DataType nestedType = ((ArrayDataType) dataType).getNestedType(); checkFieldType(field, nestedType); 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 a871da20669..51751b2e247 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 @@ -2,14 +2,20 @@ package com.yahoo.searchdefinition.processing; 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.document.*; import com.yahoo.searchdefinition.Search; import com.yahoo.searchdefinition.document.Matching; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.document.Stemming; import com.yahoo.vespa.indexinglanguage.ExpressionSearcher; -import com.yahoo.vespa.indexinglanguage.expressions.*; +import com.yahoo.vespa.indexinglanguage.expressions.ExactExpression; +import com.yahoo.vespa.indexinglanguage.expressions.Expression; +import com.yahoo.vespa.indexinglanguage.expressions.ForEachExpression; +import com.yahoo.vespa.indexinglanguage.expressions.IndexExpression; +import com.yahoo.vespa.indexinglanguage.expressions.OutputExpression; +import com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression; import com.yahoo.vespa.model.container.search.QueryProfiles; /** @@ -21,7 +27,7 @@ public class ExactMatch extends Processor { public static final String DEFAULT_EXACT_TERMINATOR = "@@"; - public ExactMatch(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + ExactMatch(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { super(search, deployLogger, rankProfileRegistry, queryProfiles); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexSettingsNonFieldNames.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexSettingsNonFieldNames.java deleted file mode 100644 index 41355a76f47..00000000000 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexSettingsNonFieldNames.java +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.searchdefinition.processing; - -import com.yahoo.config.application.api.DeployLogger; -import com.yahoo.searchdefinition.RankProfileRegistry; -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.Iterator; - -/** - * Fail if: - * 1) There are index: settings without explicit index names (name same as field name) - * 2) All the index-to indexes differ from the field name. - * - * @author Vegard Havdal - */ -public class IndexSettingsNonFieldNames extends Processor { - - public IndexSettingsNonFieldNames(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { - super(search, deployLogger, rankProfileRegistry, queryProfiles); - } - - @Override - public void process(boolean validate, boolean documentsOnly) { - if ( ! validate) return; - - for (SDField field : search.allConcreteFields()) { - boolean fieldNameUsed = false; - for (Iterator i = field.getFieldNameAsIterator(); i.hasNext();) { - String iName = (String)(i.next()); - if (iName.equals(field.getName())) { - fieldNameUsed = true; - } - } - if ( ! fieldNameUsed) { - for (Index index : field.getIndices().values()) { - if (index.getName().equals(field.getName())) { - throw new IllegalArgumentException("Error in " + field + " in " + search + - ": When all index names differ from field name, index " + - "parameter settings must specify index name explicitly."); - } - } - } - } - } - -} 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 27520647e3b..dedc96cdc05 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 @@ -2,14 +2,27 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; +import com.yahoo.document.ArrayDataType; +import com.yahoo.document.DataType; +import com.yahoo.document.MapDataType; +import com.yahoo.document.PositionDataType; +import com.yahoo.document.WeightedSetDataType; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.document.*; import com.yahoo.searchdefinition.Search; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.vespa.documentmodel.SummaryField; import com.yahoo.vespa.indexinglanguage.ExpressionConverter; -import com.yahoo.vespa.indexinglanguage.expressions.*; +import com.yahoo.vespa.indexinglanguage.expressions.AttributeExpression; +import com.yahoo.vespa.indexinglanguage.expressions.Expression; +import com.yahoo.vespa.indexinglanguage.expressions.FieldTypeAdapter; +import com.yahoo.vespa.indexinglanguage.expressions.IndexExpression; +import com.yahoo.vespa.indexinglanguage.expressions.OutputExpression; +import com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression; +import com.yahoo.vespa.indexinglanguage.expressions.StatementExpression; +import com.yahoo.vespa.indexinglanguage.expressions.SummaryExpression; +import com.yahoo.vespa.indexinglanguage.expressions.VerificationContext; +import com.yahoo.vespa.indexinglanguage.expressions.VerificationException; import com.yahoo.vespa.model.container.search.QueryProfiles; import java.util.HashSet; @@ -20,7 +33,7 @@ import java.util.Set; */ public class IndexingValidation extends Processor { - public IndexingValidation(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { + IndexingValidation(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { super(search, deployLogger, rankProfileRegistry, queryProfiles); } @@ -83,7 +96,7 @@ public class IndexingValidation extends Processor { final Search search; - public MyAdapter(Search search) { + MyAdapter(Search search) { this.search = search; } 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 b0ba8e30f06..3f225b00277 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 @@ -52,7 +52,6 @@ public class Processing { Bolding::new, AttributeProperties::new, SetRankTypeEmptyOnFilters::new, - IndexSettingsNonFieldNames::new, SummaryDynamicStructsArrays::new, StringSettingsOnNonStringFields::new, IndexingOutputs::new, 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 6bfd0ef29ea..c070a1a2126 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 @@ -2,7 +2,8 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; -import com.yahoo.document.*; +import com.yahoo.document.DataType; +import com.yahoo.document.Field; import com.yahoo.searchdefinition.Index; import com.yahoo.searchdefinition.RankProfile; import com.yahoo.searchdefinition.RankProfileRegistry; 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 d81fdf70d20..d0a0bbfb748 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 @@ -2,8 +2,11 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; +import com.yahoo.document.ArrayDataType; +import com.yahoo.document.CollectionDataType; +import com.yahoo.document.DataType; +import com.yahoo.document.WeightedSetDataType; import com.yahoo.searchdefinition.RankProfileRegistry; -import com.yahoo.document.*; import com.yahoo.searchdefinition.Search; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.document.Stemming; @@ -20,7 +23,7 @@ public class UriHack extends Processor { private static final List<String> URL_SUFFIX = Arrays.asList("scheme", "host", "port", "path", "query", "fragment", "hostname"); - public UriHack(Search search, + UriHack(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) { 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 c6b83349691..2a86247a973 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 @@ -5,7 +5,7 @@ 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.document.SDField; +import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.vespa.model.container.search.QueryProfiles; /** @@ -21,7 +21,7 @@ public class UrlFieldValidator extends Processor { public void process(boolean validate, boolean documentsOnly) { if ( ! validate) return; - for (SDField field : search.allConcreteFields()) { + for (ImmutableSDField field : search.allConcreteFields()) { if ( ! field.getDataType().equals(DataType.URI)) continue; if (field.doesAttributing()) 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 408d60e1cff..9040cffc81e 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,6 +3,7 @@ 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; 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 3bde76c1c79..58ef47b7ba9 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 @@ -14,7 +14,6 @@ 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.SDField; import com.yahoo.searchdefinition.processing.Processor; import com.yahoo.vespa.model.container.search.QueryProfiles; @@ -45,7 +44,7 @@ public class RankProfileTypeSettingsProcessor extends Processor { private void processAttributeFields() { if (search == null) return; // we're processing global profiles - for (SDField field : search.allConcreteFields()) { + for (ImmutableSDField field : search.allConcreteFields()) { Attribute attribute = field.getAttributes().get(field.getName()); if (attribute != null && attribute.tensorType().isPresent()) { addAttributeTypeToRankProfiles(attribute.getName(), attribute.tensorType().get().toString()); 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 6a94c04759f..a3d2cbcebeb 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,8 +2,8 @@ package com.yahoo.vespa.model.application.validation; import com.yahoo.config.model.deploy.DeployState; +import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.searchdefinition.document.Matching; -import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.Index; import com.yahoo.searchdefinition.Search; import com.yahoo.searchdefinition.derived.DerivedConfiguration; @@ -29,7 +29,7 @@ public class NoPrefixForIndexes extends Validator { for (DocumentDatabase docDb : sc.getDocumentDbs()) { DerivedConfiguration sdConfig = docDb.getDerivedConfiguration(); Search search = sdConfig.getSearch(); - for (SDField field : search.allConcreteFields()) { + for (ImmutableSDField field : search.allConcreteFields()) { if (field.doesIndexing()) { //if (!field.getIndexTo().isEmpty() && !field.getIndexTo().contains(field.getName())) continue; if (field.getMatching().getAlgorithm().equals(Matching.Algorithm.PREFIX)) { @@ -47,7 +47,7 @@ public class NoPrefixForIndexes extends Validator { } } - private void failField(Search search, SDField field) { + private void failField(Search search, ImmutableSDField field) { throw new IllegalArgumentException("For search '" + search.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/StreamingValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/StreamingValidator.java index e75791906bd..39478730982 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/StreamingValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/StreamingValidator.java @@ -7,8 +7,8 @@ import com.yahoo.document.DataType; import com.yahoo.document.NumericDataType; import com.yahoo.document.ReferenceDataType; import com.yahoo.searchdefinition.document.Attribute; +import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.searchdefinition.document.Matching; -import com.yahoo.searchdefinition.document.SDField; import com.yahoo.vespa.model.VespaModel; import com.yahoo.vespa.model.search.AbstractSearchCluster; import com.yahoo.vespa.model.search.SearchCluster; @@ -38,7 +38,7 @@ public class StreamingValidator extends Validator { private static void warnStreamingGramMatching(SearchCluster sc, DeployLogger logger) { if (sc.getSdConfig() != null) { - for (SDField sd : sc.getSdConfig().getSearch().allConcreteFields()) { + for (ImmutableSDField sd : sc.getSdConfig().getSearch().allConcreteFields()) { if (sd.getMatching().getType().equals(Matching.Type.GRAM)) { logger.log(Level.WARNING, "For streaming search cluster '" + sc.getClusterName() + "', SD field '" + sd.getName() + "': n-gram matching is not supported for streaming search."); @@ -55,7 +55,7 @@ public class StreamingValidator extends Validator { */ private static void warnStreamingAttributes(SearchCluster sc, DeployLogger logger) { if (sc.getSdConfig() != null) { - for (SDField sd : sc.getSdConfig().getSearch().allConcreteFields()) { + for (ImmutableSDField sd : sc.getSdConfig().getSearch().allConcreteFields()) { if (sd.doesAttributing()) { warnStreamingAttribute(sc, sd, logger); } @@ -63,7 +63,7 @@ public class StreamingValidator extends Validator { } } - private static void warnStreamingAttribute(SearchCluster sc, SDField sd, DeployLogger logger) { + private static void warnStreamingAttribute(SearchCluster sc, ImmutableSDField sd, DeployLogger logger) { // If the field is numeric, we can't print this, because we may have converted the field to // attribute indexing ourselves (IntegerIndex2Attribute) if (sd.getDataType() instanceof NumericDataType) return; 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 d680f6bd37c..049e71be23c 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 @@ -2,9 +2,9 @@ package com.yahoo.vespa.model.application.validation.change.search; import com.yahoo.searchdefinition.Search; +import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.searchdefinition.document.Matching; import com.yahoo.searchdefinition.document.NormalizeLevel; -import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.document.Stemming; import com.yahoo.vespa.documentmodel.SummaryField; import com.yahoo.vespa.documentmodel.SummaryTransform; @@ -19,12 +19,12 @@ import com.yahoo.vespa.documentmodel.SummaryTransform; public class IndexingScriptChangeMessageBuilder { private final Search currentSearch; - private final SDField currentField; + private final ImmutableSDField currentField; private final Search nextSearch; - private final SDField nextField; + private final ImmutableSDField nextField; - public IndexingScriptChangeMessageBuilder(Search currentSearch, SDField currentField, - Search nextSearch, SDField nextField) { + public IndexingScriptChangeMessageBuilder(Search currentSearch, ImmutableSDField currentField, + Search nextSearch, ImmutableSDField nextField) { this.currentSearch = currentSearch; this.currentField = currentField; this.nextSearch = nextSearch; 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 ff9230b34f3..b03141fa5d9 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 @@ -2,7 +2,7 @@ package com.yahoo.vespa.model.application.validation.change.search; import com.yahoo.searchdefinition.Search; -import com.yahoo.searchdefinition.document.SDField; +import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.vespa.indexinglanguage.ExpressionConverter; import com.yahoo.vespa.indexinglanguage.expressions.Expression; import com.yahoo.vespa.indexinglanguage.expressions.OutputExpression; @@ -35,9 +35,9 @@ public class IndexingScriptChangeValidator { public List<VespaConfigChangeAction> validate(ValidationOverrides overrides, Instant now) { List<VespaConfigChangeAction> result = new ArrayList<>(); - for (SDField nextField : nextSearch.allConcreteFields()) { + for (ImmutableSDField nextField : nextSearch.allConcreteFields()) { String fieldName = nextField.getName(); - SDField currentField = currentSearch.getConcreteField(fieldName); + ImmutableSDField currentField = currentSearch.getConcreteField(fieldName); if (currentField != null) { validateScripts(currentField, nextField, overrides, now).ifPresent(r -> result.add(r)); } @@ -45,7 +45,7 @@ public class IndexingScriptChangeValidator { return result; } - private Optional<VespaConfigChangeAction> validateScripts(SDField currentField, SDField nextField, + private Optional<VespaConfigChangeAction> validateScripts(ImmutableSDField currentField, ImmutableSDField nextField, ValidationOverrides overrides, Instant now) { ScriptExpression currentScript = currentField.getIndexingScript(); ScriptExpression nextScript = nextField.getIndexingScript(); |