diff options
author | Håkon Hallingstad <hakon.hallingstad@gmail.com> | 2022-07-12 23:11:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-12 23:11:15 +0200 |
commit | d1b77979a83f5e227175230e895c557693098e9b (patch) | |
tree | 7943b9da9e5cf6a8dc3548f8c17dc36ebfe0b8b5 /config-model/src/main | |
parent | d2e319ad2609e00b1ded032228739bbbc0ecc191 (diff) |
Revert "Validate that complex fields do not have struct fields with 'indexing…"
Diffstat (limited to 'config-model/src/main')
-rw-r--r-- | config-model/src/main/java/com/yahoo/schema/document/ImmutableImportedSDField.java | 5 | ||||
-rw-r--r-- | config-model/src/main/java/com/yahoo/schema/document/ImmutableSDField.java | 8 | ||||
-rw-r--r-- | config-model/src/main/java/com/yahoo/schema/document/SDField.java | 9 | ||||
-rw-r--r-- | config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java (renamed from config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexFieldsWithStructFieldAttributesValidator.java) | 4 | ||||
-rw-r--r-- | config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexFieldsWithStructFieldIndexesValidator.java | 72 | ||||
-rw-r--r-- | config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java | 3 |
6 files changed, 3 insertions, 98 deletions
diff --git a/config-model/src/main/java/com/yahoo/schema/document/ImmutableImportedSDField.java b/config-model/src/main/java/com/yahoo/schema/document/ImmutableImportedSDField.java index 221280dc1e4..335942de99d 100644 --- a/config-model/src/main/java/com/yahoo/schema/document/ImmutableImportedSDField.java +++ b/config-model/src/main/java/com/yahoo/schema/document/ImmutableImportedSDField.java @@ -83,11 +83,6 @@ public class ImmutableImportedSDField implements ImmutableSDField { } @Override - public boolean wasConfiguredToDoIndexing() { - return importedField.targetField().wasConfiguredToDoIndexing(); - } - - @Override public DataType getDataType() { return importedField.targetField().getDataType(); } diff --git a/config-model/src/main/java/com/yahoo/schema/document/ImmutableSDField.java b/config-model/src/main/java/com/yahoo/schema/document/ImmutableSDField.java index 37cbb3a8171..44e442811ba 100644 --- a/config-model/src/main/java/com/yahoo/schema/document/ImmutableSDField.java +++ b/config-model/src/main/java/com/yahoo/schema/document/ImmutableSDField.java @@ -45,14 +45,6 @@ public interface ImmutableSDField { */ boolean wasConfiguredToDoAttributing(); - /** - * Whether this field at some time was configured to do indexing. - * - * This function can typically return a different value than doesIndexing(), - * which uses the final state of the underlying indexing script instead. - */ - boolean wasConfiguredToDoIndexing(); - DataType getDataType(); Index getIndex(String name); diff --git a/config-model/src/main/java/com/yahoo/schema/document/SDField.java b/config-model/src/main/java/com/yahoo/schema/document/SDField.java index 2d79d89a2a0..943d6c6fc14 100644 --- a/config-model/src/main/java/com/yahoo/schema/document/SDField.java +++ b/config-model/src/main/java/com/yahoo/schema/document/SDField.java @@ -117,7 +117,6 @@ public class SDField extends Field implements TypedKey, ImmutableSDField { private boolean isExtraField = false; private boolean wasConfiguredToDoAttributing = false; - private boolean wasConfiguredToDoIndexing = false; /** * Creates a new field. This method is only used to create reserved fields. @@ -382,11 +381,6 @@ public class SDField extends Field implements TypedKey, ImmutableSDField { return wasConfiguredToDoAttributing; } - @Override - public boolean wasConfiguredToDoIndexing() { - return wasConfiguredToDoIndexing; - } - /** Parse an indexing expression which will use the simple linguistics implementation suitable for testing */ public void parseIndexingScript(String script) { parseIndexingScript(script, new SimpleLinguistics(), Embedder.throwsOnUse.asMap()); @@ -414,9 +408,6 @@ public class SDField extends Field implements TypedKey, ImmutableSDField { if (!wasConfiguredToDoAttributing()) { wasConfiguredToDoAttributing = doesAttributing(); } - if (!wasConfiguredToDoIndexing()) { - wasConfiguredToDoIndexing = doesIndexing(); - } if (!usesStructOrMap()) { new ExpressionVisitor() { diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexFieldsWithStructFieldAttributesValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java index 8515c34a377..01bf846d4cb 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexFieldsWithStructFieldAttributesValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexAttributeFieldsValidator.java @@ -22,7 +22,7 @@ import java.util.stream.Collectors; * * @author geirst */ -public class ComplexFieldsWithStructFieldAttributesValidator extends Validator { +public class ComplexAttributeFieldsValidator extends Validator { @Override public void validate(VespaModel model, DeployState deployState) { @@ -39,7 +39,7 @@ public class ComplexFieldsWithStructFieldAttributesValidator extends Validator { private static void validateComplexFields(String clusterName, Schema schema) { String unsupportedFields = schema.allFields() .filter(field -> isUnsupportedComplexField(field)) - .map(ComplexFieldsWithStructFieldAttributesValidator::toString) + .map(ComplexAttributeFieldsValidator::toString) .collect(Collectors.joining(", ")); if (!unsupportedFields.isEmpty()) { diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexFieldsWithStructFieldIndexesValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexFieldsWithStructFieldIndexesValidator.java deleted file mode 100644 index bbbb0c08bf4..00000000000 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/ComplexFieldsWithStructFieldIndexesValidator.java +++ /dev/null @@ -1,72 +0,0 @@ -// 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; - -import com.yahoo.config.model.deploy.DeployState; -import com.yahoo.schema.Schema; -import com.yahoo.schema.document.ImmutableSDField; -import com.yahoo.vespa.model.VespaModel; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.stream.Collectors; - -/** - * Validates that complex fields (of type struct or map) do not have any struct fields with 'indexing: index'. - * This is not supported and will confuse the user if not validated. - * - * Only applies for indexed search clusters. - * - * @author geirst - */ -public class ComplexFieldsWithStructFieldIndexesValidator extends Validator { - - @Override - public void validate(VespaModel model, DeployState deployState) { - for (var cluster : model.getSearchClusters()) { - if (cluster.isStreaming()) { - continue; - } - for (var spec : cluster.schemas().values()) { - validateComplexFields(cluster.getClusterName(), spec.fullSchema()); - } - } - } - - private static void validateComplexFields(String clusterName, Schema schema) { - String unsupportedFields = schema.allFields() - .filter(field -> hasStructFieldsWithIndex(field)) - .map(ComplexFieldsWithStructFieldIndexesValidator::toString) - .collect(Collectors.joining(", ")); - - if (!unsupportedFields.isEmpty()) { - throw new IllegalArgumentException( - String.format("For cluster '%s', schema '%s': The following complex fields have struct fields with 'indexing: index' which is not supported: %s. " + - "Change to 'indexing: attribute' instead", - clusterName, schema.getName(), unsupportedFields)); - } - } - - private static boolean hasStructFieldsWithIndex(ImmutableSDField field) { - return (field.usesStructOrMap() && hasStructFieldsWithIndex(field.getStructFields())); - } - - private static String toString(ImmutableSDField field) { - return field.getName() + " (" + String.join(", ", getStructFieldsWithIndex(field.getStructFields())) + ")"; - } - - private static boolean hasStructFieldsWithIndex(Collection<? extends ImmutableSDField> structFields) { - return !getStructFieldsWithIndex(structFields).isEmpty(); - } - - private static List<String> getStructFieldsWithIndex(Collection<? extends ImmutableSDField> structFields) { - var result = new ArrayList<String>(); - for (var structField : structFields) { - if (structField.wasConfiguredToDoIndexing()) { - result.add(structField.getName()); - } - result.addAll(getStructFieldsWithIndex(structField.getStructFields())); - } - return result; - } -} diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java index dab1eeccc96..ce61d3edc3b 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java @@ -71,8 +71,7 @@ public class Validation { new SchemasDirValidator().validate(model, deployState); new BundleValidator().validate(model, deployState); new SearchDataTypeValidator().validate(model, deployState); - new ComplexFieldsWithStructFieldAttributesValidator().validate(model, deployState); - new ComplexFieldsWithStructFieldIndexesValidator().validate(model, deployState); + new ComplexAttributeFieldsValidator().validate(model, deployState); new StreamingValidator().validate(model, deployState); new RankSetupValidator(validationParameters.ignoreValidationErrors()).validate(model, deployState); new NoPrefixForIndexes().validate(model, deployState); |