diff options
Diffstat (limited to 'config-model/src/main')
4 files changed, 33 insertions, 5 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java b/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java index 937d511bb09..c19865fafc9 100644 --- a/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java +++ b/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java @@ -341,7 +341,7 @@ public class DeployState implements ConfigDefinitionStore { public DeployState build(ValidationParameters validationParameters) { RankProfileRegistry rankProfileRegistry = new RankProfileRegistry(); - QueryProfiles queryProfiles = new QueryProfilesBuilder().build(applicationPackage); + QueryProfiles queryProfiles = new QueryProfilesBuilder().build(applicationPackage, logger); SemanticRules semanticRules = new SemanticRuleBuilder().build(applicationPackage); SearchDocumentModel searchDocumentModel = createSearchDocumentModel(rankProfileRegistry, logger, queryProfiles, validationParameters); return new DeployState(applicationPackage, 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 bd4daa58253..9804b0b6329 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/SearchBuilder.java @@ -246,7 +246,7 @@ public class SearchBuilder { DocumentModelBuilder 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, deployLogger, new QueryProfiles(queryProfileRegistry), validate); + process(search, deployLogger, new QueryProfiles(queryProfileRegistry, deployLogger), validate); built.add(search); } builder.addToModel(searchList); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/QueryProfiles.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/QueryProfiles.java index 526b2abe1e1..c7114178ad6 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/QueryProfiles.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/search/QueryProfiles.java @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.model.container.search; +import com.yahoo.config.application.api.DeployLogger; import com.yahoo.search.query.profile.BackedOverridableQueryProfile; import com.yahoo.search.query.profile.QueryProfile; import com.yahoo.search.query.profile.QueryProfileRegistry; @@ -12,6 +13,8 @@ import com.yahoo.search.query.profile.config.QueryProfilesConfig; import java.io.Serializable; import java.util.*; import java.util.Map.Entry; +import java.util.logging.Level; +import java.util.stream.Collectors; /** * Owns the query profiles and query profile types to be handed to the qrs nodes. @@ -29,8 +32,9 @@ public class QueryProfiles implements Serializable, QueryProfilesConfig.Producer * @param registry the registry containing the query profiles and types of this. * The given registry cannot be frozen on calling this. */ - public QueryProfiles(QueryProfileRegistry registry) { + public QueryProfiles(QueryProfileRegistry registry, DeployLogger logger) { this.registry = registry; + validate(registry, logger); } public QueryProfiles() { @@ -41,6 +45,28 @@ public class QueryProfiles implements Serializable, QueryProfilesConfig.Producer return registry; } + /** Emits warnings/hints on some common configuration errors */ + private void validate(QueryProfileRegistry registry, DeployLogger logger) { + Set<String> tensorFields = new HashSet<>(); + for (QueryProfileType type : registry.getTypeRegistry().allComponents()) { + for (var fieldEntry : type.fields().entrySet()) { + if (fieldEntry.getValue().getType().asTensorType().rank() > 0) + tensorFields.add(fieldEntry.getKey()); + } + } + + if ( registry.getTypeRegistry().hasApplicationTypes() && registry.allComponents().isEmpty()) { + logger.log(Level.WARNING, "This application define query profile types, but has " + + "no query profiles referencing them so they have no effect. " + + (tensorFields.isEmpty() + ? "" + : "In particular, the tensors (" + String.join(", ", tensorFields) + + ") will be interpreted as strings, not tensors if sent in requests. ") + + "See https://docs.vespa.ai/documentation/query-profiles.html"); + } + + } + @Override public void getConfig(QueryProfilesConfig.Builder builder) { for (QueryProfile profile : registry.allComponents()) { diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/QueryProfilesBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/QueryProfilesBuilder.java index b85cb88bf2e..b832c1bbdcd 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/QueryProfilesBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/search/QueryProfilesBuilder.java @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.model.container.search; +import com.yahoo.config.application.api.DeployLogger; import com.yahoo.io.reader.NamedReader; import com.yahoo.search.query.profile.config.QueryProfileXMLReader; import com.yahoo.config.application.api.ApplicationPackage; @@ -17,13 +18,14 @@ import java.util.List; public class QueryProfilesBuilder { /** Build the set of query profiles for an application package */ - public QueryProfiles build(ApplicationPackage applicationPackage) { + public QueryProfiles build(ApplicationPackage applicationPackage, DeployLogger logger) { List<NamedReader> queryProfileTypeFiles = null; List<NamedReader> queryProfileFiles = null; try { queryProfileTypeFiles = applicationPackage.getQueryProfileTypeFiles(); queryProfileFiles = applicationPackage.getQueryProfileFiles(); - return new QueryProfiles(new QueryProfileXMLReader().read(queryProfileTypeFiles, queryProfileFiles)); + return new QueryProfiles(new QueryProfileXMLReader().read(queryProfileTypeFiles, queryProfileFiles), + logger); } finally { NamedReader.closeAll(queryProfileTypeFiles); |