diff options
Diffstat (limited to 'config-model/src/main/java/com/yahoo/vespa/documentmodel/SummaryField.java')
-rw-r--r-- | config-model/src/main/java/com/yahoo/vespa/documentmodel/SummaryField.java | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/documentmodel/SummaryField.java b/config-model/src/main/java/com/yahoo/vespa/documentmodel/SummaryField.java index 49cd36e4bc2..1c53ee36497 100644 --- a/config-model/src/main/java/com/yahoo/vespa/documentmodel/SummaryField.java +++ b/config-model/src/main/java/com/yahoo/vespa/documentmodel/SummaryField.java @@ -1,4 +1,4 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.documentmodel; import com.yahoo.document.DataType; @@ -7,6 +7,7 @@ import com.yahoo.schema.document.TypedKey; import java.io.Serializable; import java.util.*; +import java.util.stream.Collectors; import static com.yahoo.text.Lowercase.toLowerCase; @@ -65,6 +66,7 @@ public class SummaryField extends Field implements Cloneable, TypedKey { /** True if this field was defined implicitly */ private boolean implicit = false; + private boolean unresolvedType = false; /** Creates a summary field with NONE as transform */ public SummaryField(String name, DataType type) { @@ -86,10 +88,24 @@ public class SummaryField extends Field implements Cloneable, TypedKey { this.transform=transform; } + public static SummaryField createWithUnresolvedType(String name) { + /* + * Data type is not available during conversion of + * parsed schema to schema. Use a placeholder data type and tag the summary + * field as having an unresolved type. + */ + var summaryField = new SummaryField(name, DataType.NONE); + summaryField.unresolvedType = true; + return summaryField; + } + + public void setImplicit(boolean implicit) { this.implicit=implicit; } public boolean isImplicit() { return implicit; } + public boolean hasUnresolvedType() { return unresolvedType; } + public void setTransform(SummaryTransform transform) { this.transform = transform; if (SummaryTransform.DYNAMICTEASER.equals(transform) || SummaryTransform.BOLDED.equals(transform)) { @@ -223,23 +239,18 @@ public class SummaryField extends Field implements Cloneable, TypedKey { return true; } - private String getDestinationString() - { - StringBuilder destinationString = new StringBuilder("destinations("); - for (String destination : destinations) { - destinationString.append(destination).append(" "); - } - destinationString.append(")"); - return destinationString.toString(); + private String getDestinationString() { + return destinations.stream().map(destination -> "document summary '" + destination + "'").collect(Collectors.joining(", ")); } + @Override public String toString() { return "summary field '" + getName() + "'"; } /** Returns a string which aids locating this field in the source search definition */ public String toLocateString() { - return "'summary " + getName() + " type " + toLowerCase(getDataType().getName()) + "' in '" + getDestinationString() + "'"; + return "summary " + getName() + " type " + toLowerCase(getDataType().getName()) + " in " + getDestinationString(); } @Override @@ -250,6 +261,7 @@ public class SummaryField extends Field implements Cloneable, TypedKey { clone.sources = new LinkedHashSet<>(this.sources); if (this.destinations != null) clone.destinations = new LinkedHashSet<>(destinations); + clone.unresolvedType = unresolvedType; return clone; } catch (CloneNotSupportedException e) { @@ -276,6 +288,14 @@ public class SummaryField extends Field implements Cloneable, TypedKey { return true; } + public void setResolvedDataType(DataType type) { + this.dataType = type; + if (!hasForcedId()) { + this.fieldId = calculateIdV7(null); + } + unresolvedType = false; + } + public VsmCommand getVsmCommand() { return vsmCommand; } |