diff options
author | Jon Bratseth <bratseth@gmail.com> | 2022-05-03 20:22:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-03 20:22:43 +0200 |
commit | dde286759cc3384f07b957364d3c9666aff60896 (patch) | |
tree | fa9b6fe4f2caef38b3536f92ceb703f49afc713c /container-search/src | |
parent | de8e6f7128dc6489800eae8ce8cdcc6e3414475e (diff) |
Revert "Use schema-info"
Diffstat (limited to 'container-search/src')
27 files changed, 666 insertions, 456 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java b/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java index 23ba3b0619c..3953190eac4 100644 --- a/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java +++ b/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java @@ -18,11 +18,9 @@ import com.yahoo.search.Query; import com.yahoo.search.Result; import com.yahoo.search.Searcher; import com.yahoo.search.config.ClusterConfig; -import com.yahoo.search.config.SchemaInfoConfig; import com.yahoo.search.dispatch.Dispatcher; import com.yahoo.search.query.ParameterParser; import com.yahoo.search.result.ErrorMessage; -import com.yahoo.search.schema.SchemaInfo; import com.yahoo.search.searchchain.Execution; import com.yahoo.vespa.streamingvisitors.VdsStreamingSearcher; import com.yahoo.yolean.Exceptions; @@ -78,7 +76,6 @@ public class ClusterSearcher extends Searcher { QrSearchersConfig qrsConfig, ClusterConfig clusterConfig, DocumentdbInfoConfig documentDbConfig, - SchemaInfo schemaInfo, ComponentRegistry<Dispatcher> dispatchers, VipStatus vipStatus, VespaDocumentAccess access) { @@ -102,11 +99,11 @@ public class ClusterSearcher extends Searcher { String uniqueServerId = UUID.randomUUID().toString(); if (searchClusterConfig.indexingmode() == STREAMING) { server = vdsCluster(uniqueServerId, searchClusterIndex, - searchClusterConfig, docSumParams, documentDbConfig, schemaInfo, access); + searchClusterConfig, docSumParams, documentDbConfig, access); vipStatus.addToRotation(server.getName()); } else { server = searchDispatch(searchClusterIndex, searchClusterName, uniqueServerId, - docSumParams, documentDbConfig, schemaInfo, dispatchers); + docSumParams, documentDbConfig, dispatchers); } } @@ -128,7 +125,6 @@ public class ClusterSearcher extends Searcher { String serverId, SummaryParameters docSumParams, DocumentdbInfoConfig documentdbInfoConfig, - SchemaInfo schemaInfo, ComponentRegistry<Dispatcher> dispatchers) { ClusterParams clusterParams = makeClusterParams(searchclusterIndex); ComponentId dispatcherComponentId = new ComponentId("dispatcher." + searchClusterName); @@ -136,7 +132,7 @@ public class ClusterSearcher extends Searcher { if (dispatcher == null) throw new IllegalArgumentException("Configuration error: No dispatcher " + dispatcherComponentId + " is configured"); - return new FastSearcher(serverId, dispatcher, docSumParams, clusterParams, documentdbInfoConfig, schemaInfo); + return new FastSearcher(serverId, dispatcher, docSumParams, clusterParams, documentdbInfoConfig); } private static VdsStreamingSearcher vdsCluster(String serverId, @@ -144,7 +140,6 @@ public class ClusterSearcher extends Searcher { QrSearchersConfig.Searchcluster searchClusterConfig, SummaryParameters docSumParams, DocumentdbInfoConfig documentdbInfoConfig, - SchemaInfo schemaInfo, VespaDocumentAccess access) { if (searchClusterConfig.searchdef().size() != 1) { throw new IllegalArgumentException("Search clusters in streaming search shall only contain a single searchdefinition : " + searchClusterConfig.searchdef()); @@ -154,7 +149,7 @@ public class ClusterSearcher extends Searcher { searcher.setSearchClusterName(searchClusterConfig.rankprofiles().configid()); searcher.setDocumentType(searchClusterConfig.searchdef(0)); searcher.setStorageClusterRouteSpec(searchClusterConfig.storagecluster().routespec()); - searcher.init(serverId, docSumParams, clusterParams, documentdbInfoConfig, schemaInfo); + searcher.init(serverId, docSumParams, clusterParams, documentdbInfoConfig); return searcher; } @@ -223,7 +218,7 @@ public class ClusterSearcher extends Searcher { } private Set<String> schemasHavingProfile(String profile, Execution.Context context) { - return context.schemaInfo().schemas().values().stream() + return context.schemaInfo().schemas().stream() .filter(schema -> schema.rankProfiles().containsKey(profile)) .map(schema -> schema.name()) .collect(Collectors.toSet()); @@ -239,8 +234,7 @@ public class ClusterSearcher extends Searcher { searcher.fill(result, summaryClass, execution); } else { if (result.hits().getErrorHit() == null) { - result.hits().addError(ErrorMessage.createTimeout("No time left to get summaries, query timeout was " + - query.getTimeout() + " ms")); + result.hits().addError(ErrorMessage.createTimeout("No time left to get summaries, query timeout was " + query.getTimeout() + " ms")); } } } else { diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/DocsumDefinition.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/DocsumDefinition.java index 33b912da42f..8a7d14d5f49 100644 --- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/DocsumDefinition.java +++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/DocsumDefinition.java @@ -1,11 +1,15 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.prelude.fastsearch; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.yahoo.data.access.Inspector; -import com.yahoo.search.schema.DocumentSummary; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; import java.util.Map; -import java.util.stream.Collectors; +import java.util.Set; /** * A docsum definition which knows how to decode a certain class of document @@ -17,26 +21,55 @@ import java.util.stream.Collectors; public class DocsumDefinition { private final String name; - private final Map<String, DocsumField> fields; + private final ImmutableList<DocsumField> fields; /** True if this contains dynamic fields */ private final boolean dynamic; - public DocsumDefinition(DocumentSummary documentSummary) { - this.name = documentSummary.name(); - this.dynamic = documentSummary.isDynamic(); - this.fields = documentSummary.fields() - .stream() - .map(field -> DocsumField.create(field.name(), field.type().asString())) - .collect(Collectors.toUnmodifiableMap(field -> field.getName(), - field -> field)); + // Mapping between field names and their index in this.fields + private final ImmutableMap<String, Integer> fieldNameToIndex; + + public DocsumDefinition(String name, List<DocsumField> fields) { + this.name = name; + this.dynamic = false; + this.fields = ImmutableList.copyOf(fields); + ImmutableMap.Builder<String, Integer> fieldNameToIndexBuilder = new ImmutableMap.Builder<>(); + int i = 0; + for (DocsumField field : fields) + fieldNameToIndexBuilder.put(field.name, i++); + this.fieldNameToIndex = fieldNameToIndexBuilder.build(); } - public String name() { return name; } - public Map<String, DocsumField> fields() { return fields; } + DocsumDefinition(DocumentdbInfoConfig.Documentdb.Summaryclass config) { + this.name = config.name(); - /** Returns whether this summary contains one or more dynamic fields */ - public boolean isDynamic() { return dynamic; } + List<DocsumField> fieldsBuilder = new ArrayList<>(); + Map<String, Integer> fieldNameToIndexBuilder = new HashMap<>(); + boolean dynamic = false; + for (DocumentdbInfoConfig.Documentdb.Summaryclass.Fields field : config.fields()) { + // no, don't switch the order of the two next lines :) + fieldNameToIndexBuilder.put(field.name(), fieldsBuilder.size()); + fieldsBuilder.add(DocsumField.create(field.name(), field.type())); + if (field.dynamic()) + dynamic = true; + } + this.dynamic = dynamic; + fields = ImmutableList.copyOf(fieldsBuilder); + fieldNameToIndex = ImmutableMap.copyOf(fieldNameToIndexBuilder); + } + + /** Returns the field at this index, or null if none */ + public DocsumField getField(int fieldIndex) { + if (fieldIndex >= fields.size()) return null; + return fields.get(fieldIndex); + } + + /** Returns the field with this name, or null if none */ + public DocsumField getField(String fieldName) { + Integer index = fieldNameToIndex.get(fieldName); + if (index == null) return null; + return getField(index); + } /** * Returns the given slime value as the type specified in this, or null if the type is not known. @@ -45,14 +78,35 @@ public class DocsumDefinition { * another has not. */ public Object convert(String fieldName, Inspector value) { - DocsumField field = fields.get(fieldName); - if (field == null || ! value.valid()) return null; - return field.convert(value); + DocsumField fieldType = getField(fieldName); + if (fieldType == null || ! value.valid()) return null; + return fieldType.convert(value); + } + + public Set<String> fieldNames() { + return fieldNameToIndex.keySet(); } @Override public String toString() { - return "docsum definition '" + name() + "'"; + return "docsum definition '" + getName() + "'"; + } + + public String getName() { + return name; + } + + public int getFieldCount() { + return fields.size(); + } + + public List<DocsumField> getFields() { + return fields; + } + + /** Returns whether this summary contains one or more dynamic fields */ + public boolean isDynamic() { + return dynamic; } } diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/DocsumDefinitionSet.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/DocsumDefinitionSet.java index 2b26cd29b78..1e0cfa3be9e 100644 --- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/DocsumDefinitionSet.java +++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/DocsumDefinitionSet.java @@ -1,8 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.prelude.fastsearch; -import com.yahoo.search.schema.DocumentSummary; -import com.yahoo.search.schema.Schema; +import com.google.common.collect.ImmutableMap; import com.yahoo.slime.BinaryFormat; import com.yahoo.data.access.Inspector; import com.yahoo.slime.Slime; @@ -11,6 +10,7 @@ import com.yahoo.prelude.ConfigurationException; import java.nio.ByteBuffer; import java.nio.ByteOrder; +import java.util.ArrayList; import java.util.Collection; import java.util.Map; import java.util.logging.Logger; @@ -31,15 +31,12 @@ public final class DocsumDefinitionSet { private final Map<String, DocsumDefinition> definitionsByName; - public DocsumDefinitionSet(Schema schema) { - this(schema.documentSummaries().values()); + public DocsumDefinitionSet(DocumentdbInfoConfig.Documentdb config) { + this(toDocsums(config)); } - public DocsumDefinitionSet(Collection<DocumentSummary> docsumDefinitions) { - this.definitionsByName = docsumDefinitions.stream() - .map(summary -> new DocsumDefinition(summary)) - .collect(Collectors.toUnmodifiableMap(summary -> summary.name(), - summary -> summary)); + public DocsumDefinitionSet(Collection<DocsumDefinition> docsumDefinitions) { + this.definitionsByName = ImmutableMap.copyOf(docsumDefinitions.stream().collect(Collectors.toMap(DocsumDefinition::getName, p -> p))); } /** @@ -48,15 +45,15 @@ public final class DocsumDefinitionSet { * @throws ConfigurationException if the requested summary class is not found and there is none called "default" */ public DocsumDefinition getDocsum(String summaryClass) { - if (summaryClass == null) - summaryClass = "default"; DocsumDefinition ds = definitionsByName.get(summaryClass); - if (ds == null) + if (ds == null) { ds = definitionsByName.get("default"); - if (ds == null) + } + if (ds == null) { throw new ConfigurationException("Fetched hit with summary class " + summaryClass + ", but this summary class is not in current summary config (" + this + ")" + " (that is, you asked for something unknown, and no default was found)"); + } return ds; } @@ -98,7 +95,7 @@ public final class DocsumDefinitionSet { if (sb.length() != 0) { sb.append(","); } - sb.append("[").append(e.getKey()).append(",").append(e.getValue().name()).append("]"); + sb.append("[").append(e.getKey()).append(",").append(e.getValue().getName()).append("]"); } return sb.toString(); } @@ -107,4 +104,13 @@ public final class DocsumDefinitionSet { return definitionsByName.size(); } + private static Collection<DocsumDefinition> toDocsums(DocumentdbInfoConfig.Documentdb config) { + Collection<DocsumDefinition> docsums = new ArrayList<>(); + for (int i = 0; i < config.summaryclass().size(); ++i) + docsums.add(new DocsumDefinition(config.summaryclass(i))); + if (docsums.isEmpty()) + log.warning("No summary classes found in DocumentdbInfoConfig.Documentdb"); + return docsums; + } + } diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/DocsumField.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/DocsumField.java index e6201a694cb..e412258ff15 100644 --- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/DocsumField.java +++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/DocsumField.java @@ -17,7 +17,7 @@ import java.util.logging.Logger; public abstract class DocsumField { private static final Logger log = Logger.getLogger(DocsumField.class.getName()); - private static final FieldFactory fieldFactory; + private static FieldFactory fieldFactory; private static class FieldFactory { @@ -32,7 +32,8 @@ public abstract class DocsumField { DocsumField create(String typename, String name) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { - return constructors.get(typename).newInstance(name); + DocsumField f = constructors.get(typename).newInstance(name); + return f; } } diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/DocumentDatabase.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/DocumentDatabase.java index 72ccf4aa1dd..67038e0e771 100644 --- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/DocumentDatabase.java +++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/DocumentDatabase.java @@ -2,8 +2,6 @@ package com.yahoo.prelude.fastsearch; import com.yahoo.search.schema.RankProfile; -import com.yahoo.search.schema.Schema; -import com.yahoo.search.schema.SchemaInfo; import com.yahoo.tensor.TensorType; import java.util.ArrayList; @@ -19,20 +17,48 @@ import java.util.stream.Collectors; */ public class DocumentDatabase { + // TODO: What about name conflicts when different search defs have the same rank profile/docsum? + public static final String MATCH_PROPERTY = "match"; public static final String SEARCH_DOC_TYPE_KEY = "documentdb.searchdoctype"; - private final Schema schema; + private final String name; private final DocsumDefinitionSet docsumDefSet; - public DocumentDatabase(Schema schema) { - this.schema = schema; - this.docsumDefSet = new DocsumDefinitionSet(schema); + private final Map<String, RankProfile> rankProfiles; + + public DocumentDatabase(DocumentdbInfoConfig.Documentdb documentDb) { + this(documentDb.name(), new DocsumDefinitionSet(documentDb), toRankProfiles(documentDb.rankprofile())); } - public Schema schema() { return schema; } + public DocumentDatabase(String name, DocsumDefinitionSet docsumDefinitionSet, Collection<RankProfile> rankProfiles) { + this.name = name; + this.docsumDefSet = docsumDefinitionSet; + this.rankProfiles = Map.copyOf(rankProfiles.stream().collect(Collectors.toMap(RankProfile::name, p -> p))); + } + + public String getName() { + return name; + } - /** Returns the document summary model in this which knows how to convert serialized data to hit fields. */ - public DocsumDefinitionSet getDocsumDefinitionSet() { return docsumDefSet; } + public DocsumDefinitionSet getDocsumDefinitionSet() { + return docsumDefSet; + } + + /** Returns an unmodifiable map of all the rank profiles in this indexed by rank profile name */ + public Map<String, RankProfile> rankProfiles() { return rankProfiles; } + + private static Collection<RankProfile> toRankProfiles(Collection<DocumentdbInfoConfig.Documentdb.Rankprofile> rankProfileConfigList) { + List<RankProfile> rankProfiles = new ArrayList<>(); + for (var profileConfig : rankProfileConfigList) { + var builder = new RankProfile.Builder(profileConfig.name()); + builder.setHasSummaryFeatures(profileConfig.hasSummaryFeatures()); + builder.setHasRankFeatures(profileConfig.hasRankFeatures()); + for (var inputConfig : profileConfig.input()) + builder.addInput(inputConfig.name(), TensorType.fromSpec(inputConfig.type())); + rankProfiles.add(builder.build()); + } + return rankProfiles; + } } diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java index a094be943a2..094367dc140 100644 --- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java +++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastHit.java @@ -183,7 +183,7 @@ public class FastHit extends Hit { /** For internal use */ public void addSummary(DocsumDefinition docsumDef, Inspector value) { if (removedFields != null) - removedFields.removeAll(docsumDef.fields().keySet()); + removedFields.removeAll(docsumDef.fieldNames()); if ( ! (summaries instanceof ArrayList) ) summaries = new ArrayList<>(8); summaries.add(0, new SummaryData(this, docsumDef, value, 1 + summaries.size())); } @@ -363,8 +363,8 @@ public class FastHit extends Hit { @Override public String toString() { - return super.toString() + " [fasthit, globalid: " + new GlobalId(globalId).toString() + ", partId: " + - partId + ", distributionkey: " + distributionKey + "]"; + return super.toString() + " [fasthit, globalid: " + new GlobalId(globalId).toString() + ", partId: " + + partId + ", distributionkey: " + distributionKey + "]"; } @Override @@ -562,7 +562,7 @@ public class FastHit extends Hit { void forEachFieldAsRaw(RawUtf8Consumer consumer) { data.traverse((ObjectTraverser)(name, value) -> { if (!shadowed(name) && !removed(name)) { - DocsumField fieldType = type.fields().get(name); + DocsumField fieldType = type.getField(name); if (fieldType != null) { if (fieldType.isString()) { byte[] utf8Value = value.asUtf8(); @@ -592,7 +592,7 @@ public class FastHit extends Hit { private boolean shadowed(String name) { if (hit.hasField(name)) return true; for (int i = 0; i < hit.summaries.size() - index; i++) { - if (hit.summaries.get(i).type.fields().containsKey(name)) + if (hit.summaries.get(i).type.fieldNames().contains(name)) return true; } return false; diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastSearcher.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastSearcher.java index 33ad8d8c9a8..27a45753bb5 100644 --- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastSearcher.java +++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/FastSearcher.java @@ -6,7 +6,6 @@ import com.yahoo.prelude.Pong; import com.yahoo.prelude.querytransform.QueryRewrite; import com.yahoo.search.Query; import com.yahoo.search.Result; -import com.yahoo.search.config.SchemaInfoConfig; import com.yahoo.search.dispatch.Dispatcher; import com.yahoo.search.dispatch.FillInvoker; import com.yahoo.search.dispatch.SearchInvoker; @@ -16,7 +15,6 @@ import com.yahoo.search.query.Ranking; import com.yahoo.search.result.ErrorMessage; import com.yahoo.search.result.Hit; import com.yahoo.search.result.HitGroup; -import com.yahoo.search.schema.SchemaInfo; import com.yahoo.search.searchchain.Execution; import java.io.IOException; @@ -53,13 +51,10 @@ public class FastSearcher extends VespaBackEndSearcher { * @param clusterParams the cluster number, and other cluster backend parameters * @param documentdbInfoConfig document database parameters */ - public FastSearcher(String serverId, - Dispatcher dispatcher, - SummaryParameters docSumParams, - ClusterParams clusterParams, - DocumentdbInfoConfig documentdbInfoConfig, - SchemaInfo schemaInfo) { - init(serverId, docSumParams, clusterParams, documentdbInfoConfig, schemaInfo); + public FastSearcher(String serverId, Dispatcher dispatcher, + SummaryParameters docSumParams, ClusterParams clusterParams, + DocumentdbInfoConfig documentdbInfoConfig) { + init(serverId, docSumParams, clusterParams, documentdbInfoConfig); this.dispatcher = dispatcher; } diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java index 21037be1a8b..3847e80d3c7 100644 --- a/container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java +++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/VespaBackEndSearcher.java @@ -14,12 +14,10 @@ import com.yahoo.protect.Validator; import com.yahoo.search.Query; import com.yahoo.search.Result; import com.yahoo.search.cluster.PingableSearcher; -import com.yahoo.search.config.SchemaInfoConfig; import com.yahoo.search.schema.RankProfile; import com.yahoo.search.grouping.vespa.GroupingExecutor; import com.yahoo.search.result.ErrorMessage; import com.yahoo.search.result.Hit; -import com.yahoo.search.schema.SchemaInfo; import com.yahoo.search.searchchain.Execution; import com.yahoo.searchlib.aggregation.Grouping; @@ -109,7 +107,7 @@ public abstract class VespaBackEndSearcher extends PingableSearcher { if (hasLocation(query.getModel().getQueryTree())) return true; // Needed to generate ranking features? - RankProfile rankProfile = documentDb.schema().rankProfiles().get(query.getRanking().getProfile()); + RankProfile rankProfile = documentDb.rankProfiles().get(query.getRanking().getProfile()); if (rankProfile == null) return true; // stay safe if (rankProfile.hasSummaryFeatures()) return true; if (query.getRanking().getListFeatures()) return true; @@ -135,12 +133,12 @@ public abstract class VespaBackEndSearcher extends PingableSearcher { private void resolveDocumentDatabase(Query query) { DocumentDatabase docDb = getDocumentDatabase(query); if (docDb != null) { - query.getModel().setDocumentDb(docDb.schema().name()); + query.getModel().setDocumentDb(docDb.getName()); } } public final void init(String serverId, SummaryParameters docSumParams, ClusterParams clusterParams, - DocumentdbInfoConfig documentdbInfoConfig, SchemaInfo schemaInfo) { + DocumentdbInfoConfig documentdbInfoConfig) { this.serverId = serverId; this.name = clusterParams.searcherName; @@ -150,9 +148,10 @@ public abstract class VespaBackEndSearcher extends PingableSearcher { if (documentdbInfoConfig != null) { for (DocumentdbInfoConfig.Documentdb docDb : documentdbInfoConfig.documentdb()) { - DocumentDatabase db = new DocumentDatabase(schemaInfo.schemas().get(docDb.name())); - if (documentDbs.isEmpty()) + DocumentDatabase db = new DocumentDatabase(docDb); + if (documentDbs.isEmpty()) { defaultDocumentDb = db; + } documentDbs.put(docDb.name(), db); } } @@ -160,7 +159,6 @@ public abstract class VespaBackEndSearcher extends PingableSearcher { protected void transformQuery(Query query) { } - @Override public Result search(Query query, Execution execution) { // query root should not be null here Item root = query.getModel().getQueryTree().getRoot(); @@ -393,7 +391,7 @@ public abstract class VespaBackEndSearcher extends PingableSearcher { private String decodeSummary(String summaryClass, FastHit hit, byte[] docsumdata) { DocumentDatabase db = getDocumentDatabase(hit.getQuery()); - hit.setField(Hit.SDDOCNAME_FIELD, db.schema().name()); + hit.setField(Hit.SDDOCNAME_FIELD, db.getName()); return decodeSummary(summaryClass, hit, docsumdata, db.getDocsumDefinitionSet()); } diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcProtobufFillInvoker.java b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcProtobufFillInvoker.java index 57f7ea34a97..7a5ef94069d 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcProtobufFillInvoker.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcProtobufFillInvoker.java @@ -215,7 +215,7 @@ public class RpcProtobufFillInvoker extends FillInvoker { for (int i = 0; i < hits.size(); i++) { Inspector summary = summaries.entry(i).field("docsum"); if (summary.valid()) { - hits.get(i).setField(Hit.SDDOCNAME_FIELD, documentDb.schema().name()); + hits.get(i).setField(Hit.SDDOCNAME_FIELD, documentDb.getName()); hits.get(i).addSummary(documentDb.getDocsumDefinitionSet().getDocsum(summaryClass), summary); hits.get(i).setFilled(summaryClass); } else { diff --git a/container-search/src/main/java/com/yahoo/search/schema/DocumentSummary.java b/container-search/src/main/java/com/yahoo/search/schema/DocumentSummary.java deleted file mode 100644 index 12037ee6633..00000000000 --- a/container-search/src/main/java/com/yahoo/search/schema/DocumentSummary.java +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.search.schema; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Objects; - -/** - * A document summary definition: Defines the schema on which a document hit may be - * represented in a Result. - * - * @author bratseth - */ -public class DocumentSummary { - - private final String name; - private final List<Field> fields; - private final boolean dynamic; - - private DocumentSummary(Builder builder) { - this.name = builder.name; - this.fields = List.copyOf(builder.fields); - this.dynamic = builder.dynamic; - } - - public String name() { return name; } - public List<Field> fields() { return fields; } - - /** Returns whether this contains fields which are generated dynamically from the query and field data. */ - public boolean isDynamic() { return dynamic; } - - @Override - public boolean equals(Object o) { - if (o == this) return true; - if ( ! (o instanceof DocumentSummary)) return false; - var other = (DocumentSummary)o; - if ( ! other.name.equals(this.name)) return false; - if ( other.dynamic != this.dynamic) return false; - if ( ! other.fields.equals(this.fields)) return false; - return true; - } - - @Override - public int hashCode() { - return Objects.hash(name, dynamic, fields); - } - - @Override - public String toString() { - return "document summary '" + name + "'"; - } - - public static class Builder { - - private final String name; - private final List<Field> fields = new ArrayList<>(); - private boolean dynamic; - - public Builder(String name) { - this.name = name; - } - - public Builder add(Field field) { - fields.add(field); - return this; - } - - public Builder setDynamic(boolean dynamic) { - this.dynamic = dynamic; - return this; - } - - public DocumentSummary build() { return new DocumentSummary(this); } - - } - - public static class Field { - - public enum Type { - bool, - byteType("byte"), - shortType("short"), - integer, - int64, - float16, - floatType("float"), - doubleType("double"), - string, - data, - raw, - longstring, - longdata, - jsonstring, - featuredata, - xmlstring, - tensor; - - private final String name; - - Type() { - this(null); - } - - Type(String name) { - this.name = name; - } - - /** Use this, not name() to retrieve the string value of this. */ - public String asString() { - return name != null ? name : name(); - } - - @Override - public String toString() { return asString(); } - - public static Type fromString(String name) { - return Arrays.stream(Type.values()).filter(t -> name.equals(t.asString())).findAny().orElseThrow(); - } - - } - - private final String name; - private final Type type; - - public Field(String name, String type) { - this(name, Type.fromString(type)); - } - - public Field(String name, Type type) { - this.name = name; - this.type = type; - } - - public String name() { return name; } - public Type type() { return type; } - - @Override - public boolean equals(Object o) { - if (o == this) return true; - if ( ! (o instanceof Field)) return false; - var other = (Field)o; - if ( ! other.name.equals(this.name)) return false; - if ( other.type != this.type) return false; - return true; - } - - @Override - public int hashCode() { - return Objects.hash(name, type); - } - - @Override - public String toString() { - return "summary field '" + name + "' " + type; - } - - } - -} diff --git a/container-search/src/main/java/com/yahoo/search/schema/RankProfile.java b/container-search/src/main/java/com/yahoo/search/schema/RankProfile.java index 39d4a389e6f..8267e5c937b 100644 --- a/container-search/src/main/java/com/yahoo/search/schema/RankProfile.java +++ b/container-search/src/main/java/com/yahoo/search/schema/RankProfile.java @@ -3,9 +3,7 @@ package com.yahoo.search.schema; import com.yahoo.tensor.TensorType; -import java.util.Collections; import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.Map; import java.util.Objects; @@ -25,7 +23,7 @@ public class RankProfile { this.name = builder.name; this.hasSummaryFeatures = builder.hasSummaryFeatures; this.hasRankFeatures = builder.hasRankFeatures; - this.inputs = Collections.unmodifiableMap(builder.inputs); + this.inputs = Map.copyOf(builder.inputs); } public String name() { return name; } @@ -66,7 +64,7 @@ public class RankProfile { private final String name; private boolean hasSummaryFeatures = true; private boolean hasRankFeatures = true; - private final Map<String, TensorType> inputs = new LinkedHashMap<>(); + private final Map<String, TensorType> inputs = new HashMap<>(); public Builder(String name) { this.name = Objects.requireNonNull(name); diff --git a/container-search/src/main/java/com/yahoo/search/schema/Schema.java b/container-search/src/main/java/com/yahoo/search/schema/Schema.java index 2ab5a30fbd7..b66e6ce957a 100644 --- a/container-search/src/main/java/com/yahoo/search/schema/Schema.java +++ b/container-search/src/main/java/com/yahoo/search/schema/Schema.java @@ -3,9 +3,7 @@ package com.yahoo.search.schema; import com.yahoo.api.annotations.Beta; -import java.util.Collections; import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.Map; import java.util.Objects; @@ -21,17 +19,14 @@ public class Schema { private final String name; private final Map<String, RankProfile> rankProfiles; - private final Map<String, DocumentSummary> documentSummaries; private Schema(Builder builder) { this.name = builder.name; - this.rankProfiles = Collections.unmodifiableMap(builder.rankProfiles); - this.documentSummaries = Collections.unmodifiableMap(builder.documentSummaries); + this.rankProfiles = Map.copyOf(builder.rankProfiles); } public String name() { return name; } public Map<String, RankProfile> rankProfiles() { return rankProfiles; } - public Map<String, DocumentSummary> documentSummaries() { return documentSummaries; } @Override public boolean equals(Object o) { @@ -40,13 +35,12 @@ public class Schema { Schema other = (Schema)o; if ( ! other.name.equals(this.name)) return false; if ( ! other.rankProfiles.equals(this.rankProfiles)) return false; - if ( ! other.documentSummaries.equals(this.documentSummaries)) return false; return true; } @Override public int hashCode() { - return Objects.hash(name, rankProfiles, documentSummaries); + return Objects.hash(name, rankProfiles); } @Override @@ -57,20 +51,14 @@ public class Schema { public static class Builder { private final String name; - private final Map<String, RankProfile> rankProfiles = new LinkedHashMap<>(); - private final Map<String, DocumentSummary> documentSummaries = new LinkedHashMap<>(); + private final Map<String, RankProfile> rankProfiles = new HashMap<>(); public Builder(String name) { this.name = Objects.requireNonNull(name); } public Builder add(RankProfile profile) { - rankProfiles.put(profile.name(), profile); - return this; - } - - public Builder add(DocumentSummary documentSummary) { - documentSummaries.put(documentSummary.name(), documentSummary); + rankProfiles.put(profile.name(), Objects.requireNonNull(profile)); return this; } diff --git a/container-search/src/main/java/com/yahoo/search/schema/SchemaInfo.java b/container-search/src/main/java/com/yahoo/search/schema/SchemaInfo.java index 7bd66445512..4daf110fc54 100644 --- a/container-search/src/main/java/com/yahoo/search/schema/SchemaInfo.java +++ b/container-search/src/main/java/com/yahoo/search/schema/SchemaInfo.java @@ -2,17 +2,13 @@ package com.yahoo.search.schema; import com.yahoo.api.annotations.Beta; -import com.yahoo.component.annotation.Inject; import com.yahoo.container.QrSearchersConfig; import com.yahoo.search.Query; import com.yahoo.search.config.IndexInfoConfig; import com.yahoo.search.config.SchemaInfoConfig; import com.yahoo.tensor.TensorType; -import java.util.Collection; -import java.util.Collections; import java.util.HashSet; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -43,12 +39,11 @@ public class SchemaInfo { private static final SchemaInfo empty = new SchemaInfo(List.of(), Map.of()); - private final Map<String, Schema> schemas; + private final List<Schema> schemas; /** The schemas contained in each content cluster indexed by cluster name */ private final Map<String, List<String>> clusters; - @Inject public SchemaInfo(IndexInfoConfig indexInfo, // will be used in the future SchemaInfoConfig schemaInfoConfig, QrSearchersConfig qrSearchersConfig) { @@ -56,14 +51,12 @@ public class SchemaInfo { } public SchemaInfo(List<Schema> schemas, Map<String, List<String>> clusters) { - Map<String, Schema> schemaMap = new LinkedHashMap<>(); - schemas.forEach(schema -> schemaMap.put(schema.name(), schema)); - this.schemas = Collections.unmodifiableMap(schemaMap); - this.clusters = Collections.unmodifiableMap(clusters); + this.schemas = List.copyOf(schemas); + this.clusters = Map.copyOf(clusters); } - /** Returns all schemas configured in this application, indexed by schema name. */ - public Map<String, Schema> schemas() { return schemas; } + /** Returns all schemas configured in this application. */ + public List<Schema> schemas() { return schemas; } public Session newSession(Query query) { return new Session(query.getModel().getSources(), query.getModel().getRestrict(), clusters, schemas); @@ -87,13 +80,13 @@ public class SchemaInfo { /** The schema information resolved to be relevant to this session. */ public static class Session { - private final Collection<Schema> schemas; + private final List<Schema> schemas; private Session(Set<String> sources, Set<String> restrict, Map<String, List<String>> clusters, - Map<String, Schema> candidates) { - this.schemas = resolveSchemas(sources, restrict, clusters, candidates.values()); + List<Schema> candidates) { + this.schemas = resolveSchemas(sources, restrict, clusters, candidates); } /** @@ -103,10 +96,10 @@ public class SchemaInfo { * * @return the possibly empty list of schemas matching the arguments */ - private static Collection<Schema> resolveSchemas(Set<String> sources, - Set<String> restrict, - Map<String, List<String>> clusters, - Collection<Schema> candidates) { + private static List<Schema> resolveSchemas(Set<String> sources, + Set<String> restrict, + Map<String, List<String>> clusters, + List<Schema> candidates) { if (sources.isEmpty()) return restrict.isEmpty() ? candidates : keep(restrict, candidates); @@ -121,7 +114,7 @@ public class SchemaInfo { return restrict.isEmpty() ? candidates : keep(restrict, candidates); } - private static List<Schema> keep(Set<String> names, Collection<Schema> schemas) { + private static List<Schema> keep(Set<String> names, List<Schema> schemas) { return schemas.stream().filter(schema -> names.contains(schema.name())).collect(Collectors.toList()); } diff --git a/container-search/src/main/java/com/yahoo/search/schema/SchemaInfoConfigurer.java b/container-search/src/main/java/com/yahoo/search/schema/SchemaInfoConfigurer.java index c5a74ece866..84ed9ae8e3d 100644 --- a/container-search/src/main/java/com/yahoo/search/schema/SchemaInfoConfigurer.java +++ b/container-search/src/main/java/com/yahoo/search/schema/SchemaInfoConfigurer.java @@ -1,17 +1,11 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.schema; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.yahoo.container.QrSearchersConfig; -import com.yahoo.prelude.fastsearch.DocsumDefinition; -import com.yahoo.prelude.fastsearch.DocsumField; -import com.yahoo.prelude.fastsearch.DocumentdbInfoConfig; import com.yahoo.search.config.SchemaInfoConfig; import com.yahoo.tensor.TensorType; import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -30,7 +24,6 @@ class SchemaInfoConfigurer { static Schema toSchema(SchemaInfoConfig.Schema schemaInfoConfig) { Schema.Builder builder = new Schema.Builder(schemaInfoConfig.name()); - for (var profileConfig : schemaInfoConfig.rankprofile()) { RankProfile.Builder profileBuilder = new RankProfile.Builder(profileConfig.name()); profileBuilder.setHasSummaryFeatures(profileConfig.hasSummaryFeatures()); @@ -39,17 +32,6 @@ class SchemaInfoConfigurer { profileBuilder.addInput(inputConfig.name(), TensorType.fromSpec(inputConfig.type())); builder.add(profileBuilder.build()); } - - for (var summaryConfig : schemaInfoConfig.summaryclass()) { - DocumentSummary.Builder summaryBuilder = new DocumentSummary.Builder(summaryConfig.name()); - for (var field : summaryConfig.fields()) { - if (field.dynamic()) - summaryBuilder.setDynamic(true); - summaryBuilder.add(new DocumentSummary.Field(field.name(), field.type())); - } - builder.add(summaryBuilder.build()); - } - return builder.build(); } diff --git a/container-search/src/main/java/com/yahoo/search/searchchain/ExecutionFactory.java b/container-search/src/main/java/com/yahoo/search/searchchain/ExecutionFactory.java index bf8ef39001f..3e44b02618e 100644 --- a/container-search/src/main/java/com/yahoo/search/searchchain/ExecutionFactory.java +++ b/container-search/src/main/java/com/yahoo/search/searchchain/ExecutionFactory.java @@ -2,7 +2,6 @@ package com.yahoo.search.searchchain; import com.google.inject.Inject; -import com.yahoo.api.annotations.Beta; import com.yahoo.component.AbstractComponent; import com.yahoo.component.chain.Chain; import com.yahoo.component.chain.ChainsConfigurer; @@ -49,8 +48,6 @@ public class ExecutionFactory extends AbstractComponent { private final RendererRegistry rendererRegistry; private final Executor executor; - // TODO: Fix tests depending on HandlersConfigurerTestWrapper so that this constructor can be removed - @Beta @Inject public ExecutionFactory(ChainsConfig chainsConfig, IndexInfoConfig indexInfo, @@ -61,29 +58,9 @@ public class ExecutionFactory extends AbstractComponent { Linguistics linguistics, ComponentRegistry<Renderer> renderers, Executor executor) { - this(chainsConfig, - indexInfo, - new SchemaInfo(indexInfo, schemaInfo, clusters), - clusters, - searchers, - specialTokens, - linguistics, - renderers, - executor); - } - - public ExecutionFactory(ChainsConfig chainsConfig, - IndexInfoConfig indexInfo, - SchemaInfo schemaInfo, - QrSearchersConfig clusters, - ComponentRegistry<Searcher> searchers, - SpecialtokensConfig specialTokens, - Linguistics linguistics, - ComponentRegistry<Renderer> renderers, - Executor executor) { this.searchChainRegistry = createSearchChainRegistry(searchers, chainsConfig); this.indexFacts = new IndexFacts(new IndexModel(indexInfo, clusters)).freeze(); - this.schemaInfo = schemaInfo; + this.schemaInfo = new SchemaInfo(indexInfo, schemaInfo, clusters); this.specialTokens = new SpecialTokenRegistry(specialTokens); this.linguistics = linguistics; this.renderingExecutor = createRenderingExecutor(); @@ -101,7 +78,7 @@ public class ExecutionFactory extends AbstractComponent { Linguistics linguistics, ComponentRegistry<Renderer> renderers, Executor executor) { - this(chainsConfig, indexInfo, SchemaInfo.empty(), clusters, searchers, specialTokens, linguistics, renderers, executor); + this(chainsConfig, indexInfo, new SchemaInfoConfig.Builder().build(), clusters, searchers, specialTokens, linguistics, renderers, executor); } /** @deprecated pass the container threadpool */ @@ -113,7 +90,7 @@ public class ExecutionFactory extends AbstractComponent { SpecialtokensConfig specialTokens, Linguistics linguistics, ComponentRegistry<Renderer> renderers) { - this(chainsConfig, indexInfo, SchemaInfo.empty(), clusters, searchers, specialTokens, linguistics, renderers, null); + this(chainsConfig, indexInfo, new SchemaInfoConfig.Builder().build(), clusters, searchers, specialTokens, linguistics, renderers, null); } private SearchChainRegistry createSearchChainRegistry(ComponentRegistry<Searcher> searchers, @@ -167,7 +144,7 @@ public class ExecutionFactory extends AbstractComponent { public static ExecutionFactory empty() { return new ExecutionFactory(new ChainsConfig.Builder().build(), new IndexInfoConfig.Builder().build(), - SchemaInfo.empty(), + new SchemaInfoConfig.Builder().build(), new QrSearchersConfig.Builder().build(), new ComponentRegistry<>(), new SpecialtokensConfig.Builder().build(), diff --git a/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java index 434f4bcc8e0..2d62e4c0154 100644 --- a/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/cluster/ClusterSearcherTestCase.java @@ -522,7 +522,6 @@ public class ClusterSearcherTestCase { DocumentdbInfoConfig.Builder documentDbConfig = new DocumentdbInfoConfig.Builder(); documentDbConfig.documentdb(new DocumentdbInfoConfig.Documentdb.Builder().name("type1")); - var schema = new Schema.Builder("type1"); DispatchConfig dispatchConfig = new DispatchConfig.Builder().build(); Dispatcher dispatcher = new Dispatcher(new RpcResourcePool(dispatchConfig), @@ -538,7 +537,6 @@ public class ClusterSearcherTestCase { qrSearchersConfig.build(), clusterConfig.build(), documentDbConfig.build(), - new SchemaInfo(List.of(schema.build()), Map.of()), dispatchers, vipStatus, null); diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/SlimeSummaryTestCase.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/SlimeSummaryTestCase.java index a174bde3902..8b21d1e03b2 100644 --- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/SlimeSummaryTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/SlimeSummaryTestCase.java @@ -10,8 +10,6 @@ import com.yahoo.prelude.hitfield.XMLString; import com.yahoo.search.result.FeatureData; import com.yahoo.search.result.Hit; import com.yahoo.search.result.StructuredData; -import com.yahoo.search.schema.DocumentSummary; -import com.yahoo.search.schema.Schema; import com.yahoo.slime.BinaryFormat; import com.yahoo.slime.Cursor; import com.yahoo.slime.Slime; @@ -45,7 +43,7 @@ public class SlimeSummaryTestCase { @Test public void testDecodingEmpty() { - DocsumDefinitionSet docsum = createDocsumDefinitionSet(); + DocsumDefinitionSet docsum = createDocsumDefinitionSet(summary_cf); FastHit hit = new FastHit(); assertNull(docsum.lazyDecode("default", emptySummary(), hit)); assertNull(hit.getField("integer_field")); @@ -71,7 +69,7 @@ public class SlimeSummaryTestCase { @Test public void testTimeout() { - DocsumDefinitionSet docsum = createDocsumDefinitionSet(); + DocsumDefinitionSet docsum = createDocsumDefinitionSet(summary_cf); FastHit hit = new FastHit(); assertEquals("Hit hit index:null/0/000000000000000000000000 (relevance 0.0) [fasthit, globalid: 0 0 0 0 0 0 0 0 0 0 0 0, partId: 0, distributionkey: 0] failed: Timed out....", docsum.lazyDecode("default", timeoutSummary(), hit)); @@ -81,7 +79,7 @@ public class SlimeSummaryTestCase { public void testDecoding() { Tensor tensor1 = Tensor.from("tensor(x{},y{}):{{x:foo,y:bar}:0.1}"); Tensor tensor2 = Tensor.from("tensor(x[1],y[1]):{{x:0,y:0}:-0.3}"); - DocsumDefinitionSet docsum = createDocsumDefinitionSet(); + DocsumDefinitionSet docsum = createDocsumDefinitionSet(summary_cf); FastHit hit = new FastHit(); assertNull(docsum.lazyDecode("default", fullSummary(tensor1, tensor2), hit)); assertEquals(4, hit.getField("integer_field")); @@ -129,10 +127,10 @@ public class SlimeSummaryTestCase { @Test public void testFieldAccessAPI() { - DocsumDefinitionSet partialDocsum1 = createPartialDocsumDefinitionSet1(); - DocsumDefinitionSet partialDocsum2 = createPartialDocsumDefinitionSet2(); - DocsumDefinitionSet partialDocsum3 = createPartialDocsumDefinitionSet3(); - DocsumDefinitionSet fullDocsum = createDocsumDefinitionSet(); + DocsumDefinitionSet partialDocsum1 = createDocsumDefinitionSet(partial_summary1_cf); + DocsumDefinitionSet partialDocsum2 = createDocsumDefinitionSet(partial_summary2_cf); + DocsumDefinitionSet partialDocsum3 = createDocsumDefinitionSet(partial_summary3_cf); + DocsumDefinitionSet fullDocsum = createDocsumDefinitionSet(summary_cf); FastHit hit = new FastHit(); Map<String, Object> expected = new HashMap<>(); @@ -439,59 +437,14 @@ public class SlimeSummaryTestCase { return buf.array(); } - private DocsumDefinitionSet createDocsumDefinitionSet() { - var schema = new Schema.Builder("test"); - var summary = new DocumentSummary.Builder("default"); - summary.add(new DocumentSummary.Field("integer_field", "integer")); - summary.add(new DocumentSummary.Field("short_field", "short")); - summary.add(new DocumentSummary.Field("byte_field", "byte")); - summary.add(new DocumentSummary.Field("float_field", "float")); - summary.add(new DocumentSummary.Field("double_field", "double")); - summary.add(new DocumentSummary.Field("int64_field", "int64")); - summary.add(new DocumentSummary.Field("string_field", "string")); - summary.add(new DocumentSummary.Field("data_field", "data")); - summary.add(new DocumentSummary.Field("longstring_field", "longstring")); - summary.add(new DocumentSummary.Field("longdata_field", "longdata")); - summary.add(new DocumentSummary.Field("xmlstring_field", "xmlstring")); - summary.add(new DocumentSummary.Field("jsonstring_field", "jsonstring")); - summary.add(new DocumentSummary.Field("tensor_field1", "tensor")); - summary.add(new DocumentSummary.Field("tensor_field2", "tensor")); - summary.add(new DocumentSummary.Field("summaryfeatures", "featuredata")); - schema.add(summary.build()); - return new DocsumDefinitionSet(schema.build()); - } - - private DocsumDefinitionSet createPartialDocsumDefinitionSet1() { - var schema = new Schema.Builder("test"); - var summary = new DocumentSummary.Builder("default"); - summary.add(new DocumentSummary.Field("integer_field", "integer")); - summary.add(new DocumentSummary.Field("short_field", "short")); - schema.add(summary.build()); - return new DocsumDefinitionSet(schema.build()); - } - - private DocsumDefinitionSet createPartialDocsumDefinitionSet2() { - var schema = new Schema.Builder("test"); - var summary = new DocumentSummary.Builder("default"); - summary.add(new DocumentSummary.Field("integer_field", "integer")); - summary.add(new DocumentSummary.Field("float_field", "float")); - summary.add(new DocumentSummary.Field("double_field", "double")); - schema.add(summary.build()); - return new DocsumDefinitionSet(schema.build()); - } - - private DocsumDefinitionSet createPartialDocsumDefinitionSet3() { - var schema = new Schema.Builder("test"); - var summary = new DocumentSummary.Builder("default"); - summary.add(new DocumentSummary.Field("integer_field", "integer")); - summary.add(new DocumentSummary.Field("string_field", "string")); - schema.add(summary.build()); - return new DocsumDefinitionSet(schema.build()); + private DocsumDefinitionSet createDocsumDefinitionSet(String configID) { + DocumentdbInfoConfig config = new ConfigGetter<>(DocumentdbInfoConfig.class).getConfig(configID); + return new DocsumDefinitionSet(config.documentdb(0)); } private static class Utf8FieldTraverser implements Hit.RawUtf8Consumer { - private final Map<String, Object> traversed; + private Map<String, Object> traversed; public Utf8FieldTraverser(Map<String, Object> traversed) { this.traversed = traversed; diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/partial-summary1.cfg b/container-search/src/test/java/com/yahoo/prelude/fastsearch/partial-summary1.cfg new file mode 100644 index 00000000000..5aa5c84d936 --- /dev/null +++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/partial-summary1.cfg @@ -0,0 +1,10 @@ +documentdb[1] +documentdb[0].name test +documentdb[0].summaryclass[1] +documentdb[0].summaryclass[0].name default +documentdb[0].summaryclass[0].id 1 +documentdb[0].summaryclass[0].fields[2] +documentdb[0].summaryclass[0].fields[0].name integer_field +documentdb[0].summaryclass[0].fields[0].type integer +documentdb[0].summaryclass[0].fields[1].name short_field +documentdb[0].summaryclass[0].fields[1].type short diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/partial-summary2.cfg b/container-search/src/test/java/com/yahoo/prelude/fastsearch/partial-summary2.cfg new file mode 100644 index 00000000000..bc870a63d66 --- /dev/null +++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/partial-summary2.cfg @@ -0,0 +1,12 @@ +documentdb[1] +documentdb[0].name test +documentdb[0].summaryclass[1] +documentdb[0].summaryclass[0].name default +documentdb[0].summaryclass[0].id 2 +documentdb[0].summaryclass[0].fields[3] +documentdb[0].summaryclass[0].fields[0].name integer_field +documentdb[0].summaryclass[0].fields[0].type integer +documentdb[0].summaryclass[0].fields[1].name float_field +documentdb[0].summaryclass[0].fields[1].type float +documentdb[0].summaryclass[0].fields[2].name double_field +documentdb[0].summaryclass[0].fields[2].type double diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/partial-summary3.cfg b/container-search/src/test/java/com/yahoo/prelude/fastsearch/partial-summary3.cfg new file mode 100644 index 00000000000..5d7319fd393 --- /dev/null +++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/partial-summary3.cfg @@ -0,0 +1,10 @@ +documentdb[1] +documentdb[0].name test +documentdb[0].summaryclass[1] +documentdb[0].summaryclass[0].name partial3 +documentdb[0].summaryclass[0].id 3 +documentdb[0].summaryclass[0].fields[3] +documentdb[0].summaryclass[0].fields[0].name integer_field +documentdb[0].summaryclass[0].fields[0].type integer +documentdb[0].summaryclass[0].fields[1].name string_field +documentdb[0].summaryclass[0].fields[1].type string diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/summary.cfg b/container-search/src/test/java/com/yahoo/prelude/fastsearch/summary.cfg new file mode 100644 index 00000000000..e074eadcbc2 --- /dev/null +++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/summary.cfg @@ -0,0 +1,36 @@ +documentdb[1] +documentdb[0].name test +documentdb[0].summaryclass[1] +documentdb[0].summaryclass[0].name default +documentdb[0].summaryclass[0].id 0 +documentdb[0].summaryclass[0].fields[15] +documentdb[0].summaryclass[0].fields[0].name integer_field +documentdb[0].summaryclass[0].fields[0].type integer +documentdb[0].summaryclass[0].fields[1].name short_field +documentdb[0].summaryclass[0].fields[1].type short +documentdb[0].summaryclass[0].fields[2].name byte_field +documentdb[0].summaryclass[0].fields[2].type byte +documentdb[0].summaryclass[0].fields[3].name float_field +documentdb[0].summaryclass[0].fields[3].type float +documentdb[0].summaryclass[0].fields[4].name double_field +documentdb[0].summaryclass[0].fields[4].type double +documentdb[0].summaryclass[0].fields[5].name int64_field +documentdb[0].summaryclass[0].fields[5].type int64 +documentdb[0].summaryclass[0].fields[6].name string_field +documentdb[0].summaryclass[0].fields[6].type string +documentdb[0].summaryclass[0].fields[7].name data_field +documentdb[0].summaryclass[0].fields[7].type data +documentdb[0].summaryclass[0].fields[8].name longstring_field +documentdb[0].summaryclass[0].fields[8].type longstring +documentdb[0].summaryclass[0].fields[9].name longdata_field +documentdb[0].summaryclass[0].fields[9].type longdata +documentdb[0].summaryclass[0].fields[10].name xmlstring_field +documentdb[0].summaryclass[0].fields[10].type xmlstring +documentdb[0].summaryclass[0].fields[11].name jsonstring_field +documentdb[0].summaryclass[0].fields[11].type jsonstring +documentdb[0].summaryclass[0].fields[12].name tensor_field1 +documentdb[0].summaryclass[0].fields[12].type tensor +documentdb[0].summaryclass[0].fields[13].name tensor_field2 +documentdb[0].summaryclass[0].fields[13].type tensor +documentdb[0].summaryclass[0].fields[14].name summaryfeatures +documentdb[0].summaryclass[0].fields[14].type featuredata diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/DocsumDefinitionTestCase.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/DocsumDefinitionTestCase.java index da9d849db90..6921880d725 100644 --- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/DocsumDefinitionTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/DocsumDefinitionTestCase.java @@ -1,6 +1,8 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.prelude.fastsearch.test; +import com.yahoo.config.subscription.ConfigGetter; +import com.yahoo.prelude.fastsearch.DocumentdbInfoConfig; import com.yahoo.prelude.fastsearch.ByteField; import com.yahoo.prelude.fastsearch.DataField; import com.yahoo.prelude.fastsearch.DocsumDefinition; @@ -10,8 +12,6 @@ import com.yahoo.prelude.fastsearch.IntegerField; import com.yahoo.prelude.fastsearch.StringField; import com.yahoo.document.DocumentId; import com.yahoo.document.GlobalId; -import com.yahoo.search.schema.DocumentSummary; -import com.yahoo.search.schema.Schema; import com.yahoo.slime.BinaryFormat; import com.yahoo.slime.Cursor; import com.yahoo.slime.Slime; @@ -21,8 +21,9 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; /** @@ -33,8 +34,37 @@ import static org.junit.Assert.assertTrue; public class DocsumDefinitionTestCase { @Test + public void testReading() { + String summary_cf = "file:src/test/java/com/yahoo/prelude/fastsearch/test/documentdb-info.cfg"; + DocsumDefinitionSet set = createDocsumDefinitionSet(summary_cf); + + String[] defs = new String[] { "[default,default]", "[version1,version1]", + "[withranklog,withranklog]", "[version2,version2]", "[version3,version3]", + "[version4,version4]", "[version5,version5]" }; + String setAsString = set.toString(); + for (String d : defs) { + assertFalse(setAsString.indexOf(d) == -1); + } + assertEquals(7, set.size()); + + DocsumDefinition docsum0 = set.getDocsum("default"); + + assertNotNull(docsum0); + assertEquals("default", docsum0.getName()); + assertEquals(19, docsum0.getFieldCount()); + assertNull(docsum0.getField(19)); + assertEquals("DSHOST", docsum0.getField(7).getName()); + + assertTrue(docsum0.getField(1) instanceof StringField); + assertTrue(docsum0.getField(6) instanceof ByteField); + assertTrue(docsum0.getField(7) instanceof IntegerField); + assertTrue(docsum0.getField(18) instanceof DataField); + } + + @Test public void testDecoding() { - DocsumDefinitionSet set = createDocsumDefinitionSet(); + String summary_cf = "file:src/test/java/com/yahoo/prelude/fastsearch/test/documentdb-info.cfg"; + DocsumDefinitionSet set = createDocsumDefinitionSet(summary_cf); FastHit hit = new FastHit(); set.lazyDecode(null, makeDocsum(), hit); @@ -57,6 +87,10 @@ public class DocsumDefinitionTestCase { return sb.toString(); } + public static GlobalId createGlobalId(int docId) { + return new GlobalId((new DocumentId("id:ns:type::" + docId)).getGlobalId()); + } + public static byte[] makeDocsum() { Slime slime = new Slime(); Cursor docsum = slime.setObject(); @@ -76,18 +110,9 @@ public class DocsumDefinitionTestCase { return buf.array(); } - public static DocsumDefinitionSet createDocsumDefinitionSet() { - var schema = new Schema.Builder("test"); - var summary = new DocumentSummary.Builder("default"); - summary.add(new DocumentSummary.Field("TOPIC", "string")); - summary.add(new DocumentSummary.Field("TITLE", "string")); - summary.add(new DocumentSummary.Field("DYNTEASER", "string")); - summary.add(new DocumentSummary.Field("EXTINFOSOURCE", "integer")); - summary.add(new DocumentSummary.Field("LANG1", "integer")); - summary.add(new DocumentSummary.Field("WORDS", "integer")); - summary.add(new DocumentSummary.Field("BYTES", "byte")); - schema.add(summary.build()); - return new DocsumDefinitionSet(schema.build()); + public static DocsumDefinitionSet createDocsumDefinitionSet(String configID) { + DocumentdbInfoConfig config = new ConfigGetter<>(DocumentdbInfoConfig.class).getConfig(configID); + return new DocsumDefinitionSet(config.documentdb(0)); } } diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java index c9193d08381..da93e0e845b 100644 --- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java @@ -24,17 +24,12 @@ import com.yahoo.search.grouping.request.EachOperation; import com.yahoo.search.grouping.request.GroupingOperation; import com.yahoo.search.rendering.RendererRegistry; import com.yahoo.search.result.ErrorMessage; -import com.yahoo.search.schema.DocumentSummary; -import com.yahoo.search.schema.RankProfile; -import com.yahoo.search.schema.Schema; -import com.yahoo.search.schema.SchemaInfo; import com.yahoo.search.searchchain.Execution; import org.junit.Test; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; @@ -61,8 +56,7 @@ public class FastSearcherTestCase { MockDispatcher.create(Collections.emptyList()), new SummaryParameters(null), new ClusterParams("testhittype"), - documentdbInfoConfig, - SchemaInfo.empty()); + documentdbInfoConfig); String query = "?junkparam=ignored"; Result result = doSearch(fastSearcher,new Query(query), 0, 10); @@ -96,8 +90,7 @@ public class FastSearcherTestCase { MockDispatcher.create(Collections.singletonList(new Node(0, "host0", 0))), new SummaryParameters(null), new ClusterParams("testhittype"), - documentdbInfoConfig, - SchemaInfo.empty()); + documentdbInfoConfig); Query q = new Query("?query=foo"); GroupingRequest request1 = GroupingRequest.newInstance(q); request1.setRootOperation(new AllOperation()); @@ -115,18 +108,13 @@ public class FastSearcherTestCase { @Test public void testSummaryNeedsQuery() { - var documentDb = new DocumentdbInfoConfig(new DocumentdbInfoConfig.Builder().documentdb(new DocumentdbInfoConfig.Documentdb.Builder().name("test"))); - var schema = new Schema.Builder("test") - .add(new DocumentSummary.Builder("default").build()) - .add(new RankProfile.Builder("default").setHasRankFeatures(false) - .setHasSummaryFeatures(false) - .build()); + ConfigGetter<DocumentdbInfoConfig> getter = new ConfigGetter<>(DocumentdbInfoConfig.class); + DocumentdbInfoConfig config = getter.getConfig("file:src/test/java/com/yahoo/prelude/fastsearch/test/documentdb-info.cfg"); FastSearcher backend = new FastSearcher("container.0", MockDispatcher.create(Collections.singletonList(new Node(0, "host0", 0))), new SummaryParameters(null), new ClusterParams("testhittype"), - documentDb, - new SchemaInfo(List.of(schema.build()), Map.of())); + config); Query q = new Query("?query=foo"); Result result = doSearch(backend, q, 0, 10); assertFalse(backend.summaryNeedsQuery(q)); @@ -145,8 +133,7 @@ public class FastSearcherTestCase { dispatcher, new SummaryParameters(null), new ClusterParams("testhittype"), - documentdbInfoConfig, - SchemaInfo.empty()); + documentdbInfoConfig); Query q = new Query("?query=foo"); GroupingRequest request1 = GroupingRequest.newInstance(q); request1.setRootOperation(new AllOperation()); diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/documentdb-info.cfg b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/documentdb-info.cfg new file mode 100644 index 00000000000..cc65ab2565e --- /dev/null +++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/documentdb-info.cfg @@ -0,0 +1,353 @@ +documentdb[1] +documentdb[0].name test +documentdb[0].summaryclass[7] +documentdb[0].summaryclass[0].name default +documentdb[0].summaryclass[0].id 0 +documentdb[0].summaryclass[0].fields[19] +documentdb[0].summaryclass[0].fields[0].name URL +documentdb[0].summaryclass[0].fields[0].type string +documentdb[0].summaryclass[0].fields[1].name TITLE +documentdb[0].summaryclass[0].fields[1].type string +documentdb[0].summaryclass[0].fields[2].name TEASER +documentdb[0].summaryclass[0].fields[2].type string +documentdb[0].summaryclass[0].fields[3].name TOPIC +documentdb[0].summaryclass[0].fields[3].type string +documentdb[0].summaryclass[0].fields[4].name FASTTOPIC +documentdb[0].summaryclass[0].fields[4].type string +documentdb[0].summaryclass[0].fields[5].name EXTINFO +documentdb[0].summaryclass[0].fields[5].type string +documentdb[0].summaryclass[0].fields[6].name EXTINFOSOURCE +documentdb[0].summaryclass[0].fields[6].type byte +documentdb[0].summaryclass[0].fields[7].name DSHOST +documentdb[0].summaryclass[0].fields[7].type integer +documentdb[0].summaryclass[0].fields[8].name DSKEY +documentdb[0].summaryclass[0].fields[8].type integer +documentdb[0].summaryclass[0].fields[9].name BYTES +documentdb[0].summaryclass[0].fields[9].type integer +documentdb[0].summaryclass[0].fields[10].name WORDS +documentdb[0].summaryclass[0].fields[10].type integer +documentdb[0].summaryclass[0].fields[11].name MODDATE +documentdb[0].summaryclass[0].fields[11].type integer +documentdb[0].summaryclass[0].fields[12].name CRAWLDATE +documentdb[0].summaryclass[0].fields[12].type integer +documentdb[0].summaryclass[0].fields[13].name LANG1 +documentdb[0].summaryclass[0].fields[13].type byte +documentdb[0].summaryclass[0].fields[14].name LANG2 +documentdb[0].summaryclass[0].fields[14].type byte +documentdb[0].summaryclass[0].fields[15].name LANG3 +documentdb[0].summaryclass[0].fields[15].type byte +documentdb[0].summaryclass[0].fields[16].name LANG4 +documentdb[0].summaryclass[0].fields[16].type byte +documentdb[0].summaryclass[0].fields[17].name IPADDRESS +documentdb[0].summaryclass[0].fields[17].type integer +documentdb[0].summaryclass[0].fields[18].name DOCVECTOR +documentdb[0].summaryclass[0].fields[18].type data +documentdb[0].summaryclass[1].name version1 +documentdb[0].summaryclass[1].id 1 +documentdb[0].summaryclass[1].fields[20] +documentdb[0].summaryclass[1].fields[0].name URL +documentdb[0].summaryclass[1].fields[0].type string +documentdb[0].summaryclass[1].fields[1].name TITLE +documentdb[0].summaryclass[1].fields[1].type string +documentdb[0].summaryclass[1].fields[2].name TEASER +documentdb[0].summaryclass[1].fields[2].type string +documentdb[0].summaryclass[1].fields[3].name TOPIC +documentdb[0].summaryclass[1].fields[3].type string +documentdb[0].summaryclass[1].fields[4].name FASTTOPIC +documentdb[0].summaryclass[1].fields[4].type string +documentdb[0].summaryclass[1].fields[5].name EXTINFO +documentdb[0].summaryclass[1].fields[5].type string +documentdb[0].summaryclass[1].fields[6].name EXTINFOSOURCE +documentdb[0].summaryclass[1].fields[6].type byte +documentdb[0].summaryclass[1].fields[7].name DSHOST +documentdb[0].summaryclass[1].fields[7].type integer +documentdb[0].summaryclass[1].fields[8].name DSKEY +documentdb[0].summaryclass[1].fields[8].type integer +documentdb[0].summaryclass[1].fields[9].name BYTES +documentdb[0].summaryclass[1].fields[9].type integer +documentdb[0].summaryclass[1].fields[10].name WORDS +documentdb[0].summaryclass[1].fields[10].type integer +documentdb[0].summaryclass[1].fields[11].name MODDATE +documentdb[0].summaryclass[1].fields[11].type integer +documentdb[0].summaryclass[1].fields[12].name CRAWLDATE +documentdb[0].summaryclass[1].fields[12].type integer +documentdb[0].summaryclass[1].fields[13].name LANG1 +documentdb[0].summaryclass[1].fields[13].type byte +documentdb[0].summaryclass[1].fields[14].name LANG2 +documentdb[0].summaryclass[1].fields[14].type byte +documentdb[0].summaryclass[1].fields[15].name LANG3 +documentdb[0].summaryclass[1].fields[15].type byte +documentdb[0].summaryclass[1].fields[16].name LANG4 +documentdb[0].summaryclass[1].fields[16].type byte +documentdb[0].summaryclass[1].fields[17].name IPADDRESS +documentdb[0].summaryclass[1].fields[17].type integer +documentdb[0].summaryclass[1].fields[18].name DOCVECTOR +documentdb[0].summaryclass[1].fields[18].type data +documentdb[0].summaryclass[1].fields[19].name PARTNERSITEIDS +documentdb[0].summaryclass[1].fields[19].type string +documentdb[0].summaryclass[2].name version2 +documentdb[0].summaryclass[2].id 2 +documentdb[0].summaryclass[2].fields[21] +documentdb[0].summaryclass[2].fields[0].name URL +documentdb[0].summaryclass[2].fields[0].type string +documentdb[0].summaryclass[2].fields[1].name TITLE +documentdb[0].summaryclass[2].fields[1].type string +documentdb[0].summaryclass[2].fields[2].name TEASER +documentdb[0].summaryclass[2].fields[2].type string +documentdb[0].summaryclass[2].fields[3].name TOPIC +documentdb[0].summaryclass[2].fields[3].type string +documentdb[0].summaryclass[2].fields[4].name FASTTOPIC +documentdb[0].summaryclass[2].fields[4].type string +documentdb[0].summaryclass[2].fields[5].name EXTINFO +documentdb[0].summaryclass[2].fields[5].type string +documentdb[0].summaryclass[2].fields[6].name EXTINFOSOURCE +documentdb[0].summaryclass[2].fields[6].type byte +documentdb[0].summaryclass[2].fields[7].name DSHOST +documentdb[0].summaryclass[2].fields[7].type integer +documentdb[0].summaryclass[2].fields[8].name DSKEY +documentdb[0].summaryclass[2].fields[8].type integer +documentdb[0].summaryclass[2].fields[9].name BYTES +documentdb[0].summaryclass[2].fields[9].type integer +documentdb[0].summaryclass[2].fields[10].name WORDS +documentdb[0].summaryclass[2].fields[10].type integer +documentdb[0].summaryclass[2].fields[11].name MODDATE +documentdb[0].summaryclass[2].fields[11].type integer +documentdb[0].summaryclass[2].fields[12].name CRAWLDATE +documentdb[0].summaryclass[2].fields[12].type integer +documentdb[0].summaryclass[2].fields[13].name LANG1 +documentdb[0].summaryclass[2].fields[13].type byte +documentdb[0].summaryclass[2].fields[14].name LANG2 +documentdb[0].summaryclass[2].fields[14].type byte +documentdb[0].summaryclass[2].fields[15].name LANG3 +documentdb[0].summaryclass[2].fields[15].type byte +documentdb[0].summaryclass[2].fields[16].name LANG4 +documentdb[0].summaryclass[2].fields[16].type byte +documentdb[0].summaryclass[2].fields[17].name IPADDRESS +documentdb[0].summaryclass[2].fields[17].type integer +documentdb[0].summaryclass[2].fields[18].name DOCVECTOR +documentdb[0].summaryclass[2].fields[18].type data +documentdb[0].summaryclass[2].fields[19].name PARTNERSITEIDS +documentdb[0].summaryclass[2].fields[19].type string +documentdb[0].summaryclass[2].fields[20].name DYNTEASER +documentdb[0].summaryclass[2].fields[20].type string +documentdb[0].summaryclass[3].name version3 +documentdb[0].summaryclass[3].id 3 +documentdb[0].summaryclass[3].fields[23] +documentdb[0].summaryclass[3].fields[0].name URL +documentdb[0].summaryclass[3].fields[0].type string +documentdb[0].summaryclass[3].fields[1].name TITLE +documentdb[0].summaryclass[3].fields[1].type string +documentdb[0].summaryclass[3].fields[2].name TEASER +documentdb[0].summaryclass[3].fields[2].type string +documentdb[0].summaryclass[3].fields[3].name TOPIC +documentdb[0].summaryclass[3].fields[3].type string +documentdb[0].summaryclass[3].fields[4].name FASTTOPIC +documentdb[0].summaryclass[3].fields[4].type string +documentdb[0].summaryclass[3].fields[5].name EXTINFO +documentdb[0].summaryclass[3].fields[5].type string +documentdb[0].summaryclass[3].fields[6].name EXTINFOSOURCE +documentdb[0].summaryclass[3].fields[6].type byte +documentdb[0].summaryclass[3].fields[7].name DSHOST +documentdb[0].summaryclass[3].fields[7].type integer +documentdb[0].summaryclass[3].fields[8].name DSKEY +documentdb[0].summaryclass[3].fields[8].type integer +documentdb[0].summaryclass[3].fields[9].name BYTES +documentdb[0].summaryclass[3].fields[9].type integer +documentdb[0].summaryclass[3].fields[10].name WORDS +documentdb[0].summaryclass[3].fields[10].type integer +documentdb[0].summaryclass[3].fields[11].name MODDATE +documentdb[0].summaryclass[3].fields[11].type integer +documentdb[0].summaryclass[3].fields[12].name CRAWLDATE +documentdb[0].summaryclass[3].fields[12].type integer +documentdb[0].summaryclass[3].fields[13].name LANG1 +documentdb[0].summaryclass[3].fields[13].type byte +documentdb[0].summaryclass[3].fields[14].name LANG2 +documentdb[0].summaryclass[3].fields[14].type byte +documentdb[0].summaryclass[3].fields[15].name LANG3 +documentdb[0].summaryclass[3].fields[15].type byte +documentdb[0].summaryclass[3].fields[16].name LANG4 +documentdb[0].summaryclass[3].fields[16].type byte +documentdb[0].summaryclass[3].fields[17].name IPADDRESS +documentdb[0].summaryclass[3].fields[17].type integer +documentdb[0].summaryclass[3].fields[18].name DOCVECTOR +documentdb[0].summaryclass[3].fields[18].type data +documentdb[0].summaryclass[3].fields[19].name PARTNERSITEIDS +documentdb[0].summaryclass[3].fields[19].type string +documentdb[0].summaryclass[3].fields[20].name MIMETYPE +documentdb[0].summaryclass[3].fields[20].type string +documentdb[0].summaryclass[3].fields[21].name STATICRANKLOG +documentdb[0].summaryclass[3].fields[21].type string +documentdb[0].summaryclass[3].fields[22].name DYNTEASER +documentdb[0].summaryclass[3].fields[22].type longstring +documentdb[0].summaryclass[4].name version4 +documentdb[0].summaryclass[4].id 4 +documentdb[0].summaryclass[4].fields[24] +documentdb[0].summaryclass[4].fields[0].name URL +documentdb[0].summaryclass[4].fields[0].type string +documentdb[0].summaryclass[4].fields[1].name CCURL +documentdb[0].summaryclass[4].fields[1].type string +documentdb[0].summaryclass[4].fields[2].name TITLE +documentdb[0].summaryclass[4].fields[2].type string +documentdb[0].summaryclass[4].fields[3].name TEASER +documentdb[0].summaryclass[4].fields[3].type string +documentdb[0].summaryclass[4].fields[4].name TOPIC +documentdb[0].summaryclass[4].fields[4].type string +documentdb[0].summaryclass[4].fields[5].name FASTTOPIC +documentdb[0].summaryclass[4].fields[5].type string +documentdb[0].summaryclass[4].fields[6].name EXTINFO +documentdb[0].summaryclass[4].fields[6].type string +documentdb[0].summaryclass[4].fields[7].name EXTINFOSOURCE +documentdb[0].summaryclass[4].fields[7].type byte +documentdb[0].summaryclass[4].fields[8].name DSHOST +documentdb[0].summaryclass[4].fields[8].type integer +documentdb[0].summaryclass[4].fields[9].name DSKEY +documentdb[0].summaryclass[4].fields[9].type integer +documentdb[0].summaryclass[4].fields[10].name BYTES +documentdb[0].summaryclass[4].fields[10].type integer +documentdb[0].summaryclass[4].fields[11].name WORDS +documentdb[0].summaryclass[4].fields[11].type integer +documentdb[0].summaryclass[4].fields[12].name MODDATE +documentdb[0].summaryclass[4].fields[12].type integer +documentdb[0].summaryclass[4].fields[13].name CRAWLDATE +documentdb[0].summaryclass[4].fields[13].type integer +documentdb[0].summaryclass[4].fields[14].name LANG1 +documentdb[0].summaryclass[4].fields[14].type byte +documentdb[0].summaryclass[4].fields[15].name LANG2 +documentdb[0].summaryclass[4].fields[15].type byte +documentdb[0].summaryclass[4].fields[16].name LANG3 +documentdb[0].summaryclass[4].fields[16].type byte +documentdb[0].summaryclass[4].fields[17].name LANG4 +documentdb[0].summaryclass[4].fields[17].type byte +documentdb[0].summaryclass[4].fields[18].name IPADDRESS +documentdb[0].summaryclass[4].fields[18].type integer +documentdb[0].summaryclass[4].fields[19].name DOCVECTOR +documentdb[0].summaryclass[4].fields[19].type data +documentdb[0].summaryclass[4].fields[20].name PARTNERSITEIDS +documentdb[0].summaryclass[4].fields[20].type string +documentdb[0].summaryclass[4].fields[21].name MIMETYPE +documentdb[0].summaryclass[4].fields[21].type string +documentdb[0].summaryclass[4].fields[22].name STATICRANKLOG +documentdb[0].summaryclass[4].fields[22].type string +documentdb[0].summaryclass[4].fields[23].name DYNTEASER +documentdb[0].summaryclass[4].fields[23].type longstring +documentdb[0].summaryclass[5].name version5 +documentdb[0].summaryclass[5].id 5 +documentdb[0].summaryclass[5].fields[25] +documentdb[0].summaryclass[5].fields[0].name URL +documentdb[0].summaryclass[5].fields[0].type string +documentdb[0].summaryclass[5].fields[1].name URLLIST +documentdb[0].summaryclass[5].fields[1].type string +documentdb[0].summaryclass[5].fields[2].name CCURL +documentdb[0].summaryclass[5].fields[2].type string +documentdb[0].summaryclass[5].fields[3].name TITLE +documentdb[0].summaryclass[5].fields[3].type string +documentdb[0].summaryclass[5].fields[4].name TEASER +documentdb[0].summaryclass[5].fields[4].type string +documentdb[0].summaryclass[5].fields[5].name TOPIC +documentdb[0].summaryclass[5].fields[5].type string +documentdb[0].summaryclass[5].fields[6].name FASTTOPIC +documentdb[0].summaryclass[5].fields[6].type string +documentdb[0].summaryclass[5].fields[7].name EXTINFO +documentdb[0].summaryclass[5].fields[7].type string +documentdb[0].summaryclass[5].fields[8].name EXTINFOSOURCE +documentdb[0].summaryclass[5].fields[8].type byte +documentdb[0].summaryclass[5].fields[9].name DSHOST +documentdb[0].summaryclass[5].fields[9].type integer +documentdb[0].summaryclass[5].fields[10].name DSKEY +documentdb[0].summaryclass[5].fields[10].type integer +documentdb[0].summaryclass[5].fields[11].name BYTES +documentdb[0].summaryclass[5].fields[11].type integer +documentdb[0].summaryclass[5].fields[12].name WORDS +documentdb[0].summaryclass[5].fields[12].type integer +documentdb[0].summaryclass[5].fields[13].name MODDATE +documentdb[0].summaryclass[5].fields[13].type integer +documentdb[0].summaryclass[5].fields[14].name CRAWLDATE +documentdb[0].summaryclass[5].fields[14].type integer +documentdb[0].summaryclass[5].fields[15].name LANG1 +documentdb[0].summaryclass[5].fields[15].type byte +documentdb[0].summaryclass[5].fields[16].name LANG2 +documentdb[0].summaryclass[5].fields[16].type byte +documentdb[0].summaryclass[5].fields[17].name LANG3 +documentdb[0].summaryclass[5].fields[17].type byte +documentdb[0].summaryclass[5].fields[18].name LANG4 +documentdb[0].summaryclass[5].fields[18].type byte +documentdb[0].summaryclass[5].fields[19].name IPADDRESS +documentdb[0].summaryclass[5].fields[19].type integer +documentdb[0].summaryclass[5].fields[20].name DOCVECTOR +documentdb[0].summaryclass[5].fields[20].type data +documentdb[0].summaryclass[5].fields[21].name PARTNERSITEIDS +documentdb[0].summaryclass[5].fields[21].type string +documentdb[0].summaryclass[5].fields[22].name MIMETYPE +documentdb[0].summaryclass[5].fields[22].type string +documentdb[0].summaryclass[5].fields[23].name STATICRANKLOG +documentdb[0].summaryclass[5].fields[23].type string +documentdb[0].summaryclass[5].fields[24].name DYNTEASER +documentdb[0].summaryclass[5].fields[24].type longstring +documentdb[0].summaryclass[6].name withranklog +documentdb[0].summaryclass[6].id 237 +documentdb[0].summaryclass[6].fields[31] +documentdb[0].summaryclass[6].fields[0].name BYTES +documentdb[0].summaryclass[6].fields[0].type integer +documentdb[0].summaryclass[6].fields[1].name CCURL +documentdb[0].summaryclass[6].fields[1].type string +documentdb[0].summaryclass[6].fields[2].name CRAWLDATE +documentdb[0].summaryclass[6].fields[2].type integer +documentdb[0].summaryclass[6].fields[3].name DOCVECTOR +documentdb[0].summaryclass[6].fields[3].type data +documentdb[0].summaryclass[6].fields[4].name DSHOST +documentdb[0].summaryclass[6].fields[4].type integer +documentdb[0].summaryclass[6].fields[5].name DSKEY +documentdb[0].summaryclass[6].fields[5].type integer +documentdb[0].summaryclass[6].fields[6].name DYNTEASER +documentdb[0].summaryclass[6].fields[6].type longstring +documentdb[0].summaryclass[6].fields[7].name DYNTEASERINPUT +documentdb[0].summaryclass[6].fields[7].type longstring +documentdb[0].summaryclass[6].fields[8].name EXTINFO +documentdb[0].summaryclass[6].fields[8].type string +documentdb[0].summaryclass[6].fields[9].name EXTINFOSOURCE +documentdb[0].summaryclass[6].fields[9].type byte +documentdb[0].summaryclass[6].fields[10].name FASTTOPIC +documentdb[0].summaryclass[6].fields[10].type string +documentdb[0].summaryclass[6].fields[11].name IPADDRESS +documentdb[0].summaryclass[6].fields[11].type integer +documentdb[0].summaryclass[6].fields[12].name JUNIPER +documentdb[0].summaryclass[6].fields[12].type longstring +documentdb[0].summaryclass[6].fields[13].name JUNIPERMETRIC +documentdb[0].summaryclass[6].fields[13].type integer +documentdb[0].summaryclass[6].fields[14].name LABEL +documentdb[0].summaryclass[6].fields[14].type string +documentdb[0].summaryclass[6].fields[15].name LANG1 +documentdb[0].summaryclass[6].fields[15].type byte +documentdb[0].summaryclass[6].fields[16].name LANG2 +documentdb[0].summaryclass[6].fields[16].type byte +documentdb[0].summaryclass[6].fields[17].name LANG3 +documentdb[0].summaryclass[6].fields[17].type byte +documentdb[0].summaryclass[6].fields[18].name LANG4 +documentdb[0].summaryclass[6].fields[18].type byte +documentdb[0].summaryclass[6].fields[19].name MIMETYPE +documentdb[0].summaryclass[6].fields[19].type string +documentdb[0].summaryclass[6].fields[20].name MODDATE +documentdb[0].summaryclass[6].fields[20].type integer +documentdb[0].summaryclass[6].fields[21].name PARTNERSITEIDS +documentdb[0].summaryclass[6].fields[21].type string +documentdb[0].summaryclass[6].fields[22].name RANKLOG +documentdb[0].summaryclass[6].fields[22].type string +documentdb[0].summaryclass[6].fields[23].name STATICRANK +documentdb[0].summaryclass[6].fields[23].type integer +documentdb[0].summaryclass[6].fields[24].name STATICRANKLOG +documentdb[0].summaryclass[6].fields[24].type string +documentdb[0].summaryclass[6].fields[25].name TEASER +documentdb[0].summaryclass[6].fields[25].type string +documentdb[0].summaryclass[6].fields[26].name TITLE +documentdb[0].summaryclass[6].fields[26].type string +documentdb[0].summaryclass[6].fields[27].name TOPIC +documentdb[0].summaryclass[6].fields[27].type string +documentdb[0].summaryclass[6].fields[28].name URL +documentdb[0].summaryclass[6].fields[28].type string +documentdb[0].summaryclass[6].fields[29].name URLLIST +documentdb[0].summaryclass[6].fields[29].type string +documentdb[0].summaryclass[6].fields[30].name WORDS +documentdb[0].summaryclass[6].fields[30].type integer +documentdb[0].rankprofile[0].name "default" +documentdb[0].rankprofile[0].hasSummaryFeatures false +documentdb[0].rankprofile[0].hasRankFeatures false diff --git a/container-search/src/test/java/com/yahoo/search/grouping/vespa/HitConverterTestCase.java b/container-search/src/test/java/com/yahoo/search/grouping/vespa/HitConverterTestCase.java index 6c66c8f4ca6..ba54c3808f2 100644 --- a/container-search/src/test/java/com/yahoo/search/grouping/vespa/HitConverterTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/grouping/vespa/HitConverterTestCase.java @@ -13,8 +13,6 @@ import com.yahoo.search.Result; import com.yahoo.search.Searcher; import com.yahoo.search.result.Hit; import com.yahoo.search.result.Relevance; -import com.yahoo.search.schema.DocumentSummary; -import com.yahoo.search.schema.Schema; import com.yahoo.search.searchchain.Execution; import com.yahoo.searchlib.aggregation.FS4Hit; import com.yahoo.searchlib.aggregation.VdsHit; @@ -100,17 +98,17 @@ public class HitConverterTestCase { return new GroupingListHit(Collections.emptyList(), null); } - private static DocsumDefinitionSet sixtynine() { - var schema = new Schema.Builder("none"); - var summary = new DocumentSummary.Builder("69"); - schema.add(summary.build()); - return new DocsumDefinitionSet(schema.build()); + private static DocumentdbInfoConfig.Documentdb sixtynine() { + DocumentdbInfoConfig.Documentdb.Builder summaryConfig = new DocumentdbInfoConfig.Documentdb.Builder(); + summaryConfig.name("none"); + summaryConfig.summaryclass(new DocumentdbInfoConfig.Documentdb.Summaryclass.Builder().id(0).name("69")); + return new DocumentdbInfoConfig.Documentdb(summaryConfig); } @Test public void requireThatVdsHitCanBeConverted() { HitConverter converter = new HitConverter(new MySearcher(), new Query()); - GroupingListHit context = new GroupingListHit(null, sixtynine()); + GroupingListHit context = new GroupingListHit(null, new DocsumDefinitionSet(sixtynine())); VdsHit lowHit = new VdsHit("id:ns:type::", new byte[] { 0x55, 0x55, 0x55, 0x55 }, 1); lowHit.setContext(context); Hit hit = converter.toSearchHit("69", lowHit); diff --git a/container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTester.java b/container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTester.java index 45bf5af5258..ff996464c4a 100644 --- a/container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTester.java +++ b/container-search/src/test/java/com/yahoo/search/schema/SchemaInfoTester.java @@ -69,11 +69,6 @@ public class SchemaInfoTester { .add(new RankProfile.Builder("inconsistent") .addInput("query(myTensor1)", TensorType.fromSpec("tensor(a{},b{})")) .build()) - .add(new DocumentSummary.Builder("testSummary") - .add(new DocumentSummary.Field("field1", "string")) - .add(new DocumentSummary.Field("field2", "integer")) - .setDynamic(true) - .build()) .build()); schemas.add(new Schema.Builder("b") .add(common) @@ -103,32 +98,17 @@ public class SchemaInfoTester { var schemaInfoInfoConfig = new SchemaInfoConfig.Builder(); - // ----- Schema A var schemaA = new SchemaInfoConfig.Schema.Builder(); schemaA.name("a"); - schemaA.rankprofile(rankProfileCommon); var rankProfileInconsistentA = new SchemaInfoConfig.Schema.Rankprofile.Builder(); rankProfileInconsistentA.name("inconsistent"); rankProfileInconsistentA.input(new SchemaInfoConfig.Schema.Rankprofile.Input.Builder().name("query(myTensor1)").type("tensor(a{},b{})")); schemaA.rankprofile(rankProfileInconsistentA); - - var summaryClass = new SchemaInfoConfig.Schema.Summaryclass.Builder(); - summaryClass.name("testSummary"); - var field1 = new SchemaInfoConfig.Schema.Summaryclass.Fields.Builder(); - field1.name("field1").type("string").dynamic(true); - summaryClass.fields(field1); - var field2 = new SchemaInfoConfig.Schema.Summaryclass.Fields.Builder(); - field2.name("field2").type("integer"); - summaryClass.fields(field2); - schemaA.summaryclass(summaryClass); - schemaInfoInfoConfig.schema(schemaA); - // ----- Schema B var schemaB = new SchemaInfoConfig.Schema.Builder(); schemaB.name("b"); - schemaB.rankprofile(rankProfileCommon); var rankProfileInconsistentB = new SchemaInfoConfig.Schema.Rankprofile.Builder(); rankProfileInconsistentB.name("inconsistent"); @@ -138,10 +118,8 @@ public class SchemaInfoTester { rankProfileBOnly.name("bOnly"); rankProfileBOnly.input(new SchemaInfoConfig.Schema.Rankprofile.Input.Builder().name("query(myTensor1)").type("tensor(a{},b{})")); schemaB.rankprofile(rankProfileBOnly); - schemaInfoInfoConfig.schema(schemaB); - // ----- Info about which schemas are in which clusters var qrSearchersConfig = new QrSearchersConfig.Builder(); var clusterAB = new QrSearchersConfig.Searchcluster.Builder(); clusterAB.name("ab"); diff --git a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/VdsStreamingSearcherTestCase.java b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/VdsStreamingSearcherTestCase.java index 861be9a3ade..1f074eeae78 100644 --- a/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/VdsStreamingSearcherTestCase.java +++ b/container-search/src/test/java/com/yahoo/vespa/streamingvisitors/VdsStreamingSearcherTestCase.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.vespa.streamingvisitors; +import com.yahoo.config.subscription.ConfigGetter; import com.yahoo.document.select.parser.TokenMgrException; import com.yahoo.messagebus.Trace; import com.yahoo.messagebus.routing.Route; @@ -12,8 +13,6 @@ import com.yahoo.prelude.fastsearch.TimeoutException; import com.yahoo.search.Query; import com.yahoo.search.Result; import com.yahoo.search.result.Hit; -import com.yahoo.search.schema.Schema; -import com.yahoo.search.schema.SchemaInfo; import com.yahoo.search.searchchain.Execution; import com.yahoo.searchlib.aggregation.Grouping; import com.yahoo.vdslib.DocumentSummary; @@ -220,13 +219,12 @@ public class VdsStreamingSearcherTestCase { MockVisitorFactory factory = new MockVisitorFactory(); VdsStreamingSearcher searcher = new VdsStreamingSearcher(factory); - var schema = new Schema.Builder("test"); - schema.add(new com.yahoo.search.schema.DocumentSummary.Builder("default").build()); + ConfigGetter<DocumentdbInfoConfig> getter = new ConfigGetter<>(DocumentdbInfoConfig.class); + DocumentdbInfoConfig config = getter.getConfig("file:src/test/java/com/yahoo/prelude/fastsearch/test/documentdb-info.cfg"); searcher.init("container.0", new SummaryParameters("default"), new ClusterParams("clusterName"), - new DocumentdbInfoConfig.Builder().documentdb(new DocumentdbInfoConfig.Documentdb.Builder().name("test")).build(), - new SchemaInfo(List.of(schema.build()), Map.of())); + config); // Magic query values are used to trigger specific behaviors from mock visitor. checkError(searcher, "/?query=noselection", |