Class SDField

java.lang.Object
com.yahoo.vespa.objects.FieldBase
com.yahoo.document.Field
com.yahoo.schema.document.SDField
All Implemented Interfaces:
com.yahoo.document.fieldset.FieldSet, ImmutableSDField, TypedKey, Comparable<com.yahoo.document.Field>
Direct Known Subclasses:
TemporarySDField

public class SDField extends com.yahoo.document.Field implements TypedKey, ImmutableSDField
The field class represents a document field. It is used in the Document class to get and set fields. Each SDField has a name, a numeric ID, a data type. The numeric ID is used when the fields are stored in serialized form.
Author:
bratseth
  • Constructor Details

    • SDField

      public SDField(SDDocumentType repo, String name, int id, com.yahoo.document.DataType dataType)
      Creates a new field. This method is only used to create reserved fields.
      Parameters:
      name - the name of the field
      dataType - the datatype of the field
    • SDField

      public SDField(String name, com.yahoo.document.DataType dataType)
    • SDField

      public SDField(SDDocumentType repo, String name, com.yahoo.document.DataType dataType)
      Creates a new field
    • SDField

      protected SDField(SDDocumentType repo, String name, com.yahoo.document.DataType dataType, SDDocumentType owner)
      Creates a new field
    • SDField

      protected SDField(SDDocumentType repo, String name, com.yahoo.document.DataType dataType, SDDocumentType owner, Matching fieldMatching, int recursion)
      Creates a new field
      Parameters:
      name - the name of the field
      dataType - the datatype of the field
      owner - the owning document (used to check for id collisions)
      fieldMatching - the matching object to set for the field
  • Method Details

    • setIsExtraField

      public void setIsExtraField(boolean isExtra)
    • isExtraField

      public boolean isExtraField()
      Specified by:
      isExtraField in interface ImmutableSDField
    • isImportedField

      public boolean isImportedField()
      Specified by:
      isImportedField in interface ImmutableSDField
    • doesAttributing

      public boolean doesAttributing()
      Specified by:
      doesAttributing in interface ImmutableSDField
    • doesIndexing

      public boolean doesIndexing()
      Specified by:
      doesIndexing in interface ImmutableSDField
    • doesSummarying

      public boolean doesSummarying()
    • doesLowerCasing

      public boolean doesLowerCasing()
      Specified by:
      doesLowerCasing in interface ImmutableSDField
    • containsExpression

      public <T extends com.yahoo.vespa.indexinglanguage.expressions.Expression> boolean containsExpression(Class<T> searchFor)
      Specified by:
      containsExpression in interface ImmutableSDField
    • addSummaryFieldSources

      public void addSummaryFieldSources(SummaryField summaryField)
    • setId

      public void setId(int fieldId, com.yahoo.document.DocumentType owner)
      Overrides:
      setId in class com.yahoo.document.Field
    • getFirstStructRecursive

      public com.yahoo.document.StructDataType getFirstStructRecursive()
    • usesStructOrMap

      public boolean usesStructOrMap()
      Specified by:
      usesStructOrMap in interface ImmutableSDField
    • wasConfiguredToDoAttributing

      public boolean wasConfiguredToDoAttributing()
      Description copied from interface: ImmutableSDField
      Whether this field at some time was configured to do attributing. This function can typically return a different value than doesAttributing(), which uses the final state of the underlying indexing script instead.
      Specified by:
      wasConfiguredToDoAttributing in interface ImmutableSDField
    • wasConfiguredToDoIndexing

      public boolean wasConfiguredToDoIndexing()
      Description copied from interface: ImmutableSDField
      Whether this field at some time was configured to do indexing. This function can typically return a different value than doesIndexing(), which uses the final state of the underlying indexing script instead.
      Specified by:
      wasConfiguredToDoIndexing in interface ImmutableSDField
    • hasSingleAttribute

      public boolean hasSingleAttribute()
      Description copied from interface: ImmutableSDField
      Returns whether this field has a single attribute with the same name as this field.
      Specified by:
      hasSingleAttribute in interface ImmutableSDField
    • parseIndexingScript

      public void parseIndexingScript(String script)
      Parse an indexing expression which will use the simple linguistics implementation suitable for testing
    • parseIndexingScript

      public void parseIndexingScript(String script, com.yahoo.language.Linguistics linguistics, Map<String,com.yahoo.language.process.Embedder> embedders)
    • setIndexingScript

      public void setIndexingScript(com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression exp)
      Sets the indexing script of this, or null to not use a script
    • getIndexingScript

      public com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression getIndexingScript()
      Specified by:
      getIndexingScript in interface ImmutableSDField
    • setDataType

      public void setDataType(com.yahoo.document.DataType type)
      Specified by:
      setDataType in interface TypedKey
      Overrides:
      setDataType in class com.yahoo.document.Field
    • isIndexStructureField

      public boolean isIndexStructureField()
      Specified by:
      isIndexStructureField in interface ImmutableSDField
    • setIndexStructureField

      public void setIndexStructureField(boolean indexStructureField)
    • hasIndex

      public boolean hasIndex()
      Specified by:
      hasIndex in interface ImmutableSDField
    • setLiteralBoost

      public void setLiteralBoost(int literalBoost)
      Sets the literal boost of this field
    • getLiteralBoost

      public int getLiteralBoost()
      Returns the literal boost of this field. This boost is added to a literal score when a query term matched as query term exactly (unnormalized and unstemmed). Default is non-positive.
      Specified by:
      getLiteralBoost in interface ImmutableSDField
    • setWeight

      public void setWeight(int weight)
      Sets the weight of this field
    • getWeight

      public int getWeight()
      Returns the weight of this field, or 0 if nothing is set
      Specified by:
      getWeight in interface ImmutableSDField
    • getMatching

      public Matching getMatching()
      Returns what kind of matching type should be applied.
      Specified by:
      getMatching in interface ImmutableSDField
    • setMatching

      public void setMatching(Matching matching)
      Sets what kind of matching type should be applied. (Token matching is default, PREFIX, SUBSTRING, SUFFIX are alternatives)
    • getDictionary

      public Dictionary getDictionary()
      Returns Dictionary settings.
    • getOrSetDictionary

      public Dictionary getOrSetDictionary()
    • setMatchingType

      public void setMatchingType(MatchType type)
      Set the matching type for this field and all subfields.
    • setMatchingCase

      public void setMatchingCase(Case casing)
      Set the matching type for this field and all subfields.
    • setMatchingAlgorithm

      public void setMatchingAlgorithm(MatchAlgorithm algorithm)
      Set matching algorithm for this field and all subfields.
    • addIndex

      public void addIndex(Index index)
      Adds an explicit index defined in this field
    • getIndex

      public Index getIndex(String name)
      Returns an index, or null if no index with this name has had some explicit settings applied in this field (even if this returns null, the index may be implicitly defined by an indexing statement)
      Specified by:
      getIndex in interface ImmutableSDField
    • existsIndex

      public boolean existsIndex(String name)
      Returns an index if this field has one (implicitly or explicitly) targeting the given name.
      Specified by:
      existsIndex in interface ImmutableSDField
    • getIndices

      public Map<String,Index> getIndices()
      Defined indices on this field
      Specified by:
      getIndices in interface ImmutableSDField
      Returns:
      defined indices on this
    • setRankType

      public void setRankType(RankType rankType)
      Sets the default rank type of this fields indices, and sets this rank type to all indices explicitly defined here which has no index set. (This complex behavior is dues to the fact than we would prefer to have rank types per field, not per index)
    • getRanking

      public Ranking getRanking()
      Returns the rank settings set in a "rank" block for this field. This is never null.
      Specified by:
      getRanking in interface ImmutableSDField
    • getRankType

      public RankType getRankType()
      Returns the default rank type of indices of this field, or null if nothing is set
      Specified by:
      getRankType in interface ImmutableSDField
    • getAttributes

      public Map<String,Attribute> getAttributes()
      Returns the search-time attribute settings of this field or null if none is set.

      TODO: Make unmodifiable.

      Specified by:
      getAttributes in interface ImmutableSDField
    • getAttribute

      public Attribute getAttribute()
      Specified by:
      getAttribute in interface ImmutableSDField
    • addAttribute

      public void addAttribute(Attribute attribute)
    • getStemming

      public Stemming getStemming()
      Returns the stemming setting of this field. Default is determined by the owning search definition.
      Specified by:
      getStemming in interface ImmutableSDField
      Returns:
      the stemming setting of this, or null, to use the default
    • getStemming

      public Stemming getStemming(Schema schema)
      Whether this field should be stemmed in this search definition
      Specified by:
      getStemming in interface ImmutableSDField
    • asField

      public com.yahoo.document.Field asField()
      Description copied from interface: ImmutableSDField
      Returns a Field representation (which is sadly not immutable)
      Specified by:
      asField in interface ImmutableSDField
    • setStemming

      public void setStemming(Stemming stemming)
      Sets how this field should be stemmed, or set to null to use the default.
    • getSummaryFields

      public Map<String,SummaryField> getSummaryFields()
      Returns an unmodifiable map of the summary fields defined in this
      Specified by:
      getSummaryFields in interface ImmutableSDField
    • removeSummaryFields

      public void removeSummaryFields()
    • addSummaryField

      public void addSummaryField(SummaryField summaryField)
      Adds a summary field
    • getSummaryField

      public SummaryField getSummaryField(String name)
      Returns a summary field defined (implicitly or explicitly) by this field. Returns null if there is no such summary field defined.
      Specified by:
      getSummaryField in interface ImmutableSDField
    • getSummaryField

      public SummaryField getSummaryField(String name, boolean create)
      Returns a summary field defined (implicitly or explicitly) by this field.
      Parameters:
      create - true to create the summary field and add it to this field before returning if it is missing
      Returns:
      the summary field, or null if not present and create is false
    • getStructFields

      public Collection<SDField> getStructFields()
      Returns list of static struct fields
      Specified by:
      getStructFields in interface ImmutableSDField
    • getStructField

      public SDField getStructField(String name)
      Returns a struct field defined in this field, potentially traversing into nested structs. Returns null if there is no such struct field defined.
      Specified by:
      getStructField in interface ImmutableSDField
    • getNormalizing

      public NormalizeLevel getNormalizing()
      Returns how the content of this field should be accent normalized etc
      Specified by:
      getNormalizing in interface ImmutableSDField
    • setNormalizing

      public void setNormalizing(NormalizeLevel level)
      Change how the content of this field should be accent normalized etc
    • addQueryCommand

      public void addQueryCommand(String name)
    • hasQueryCommand

      public boolean hasQueryCommand(String name)
    • getQueryCommands

      public List<String> getQueryCommands()
      Returns a list of query commands
      Specified by:
      getQueryCommands in interface ImmutableSDField
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class com.yahoo.document.Field
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class com.yahoo.document.Field
    • toString

      public String toString()
      Overrides:
      toString in class com.yahoo.document.Field
    • getAliasToName

      public Map<String,String> getAliasToName()
      The aliases declared for this field
      Specified by:
      getAliasToName in interface ImmutableSDField
    • hasFullIndexingDocprocRights

      public boolean hasFullIndexingDocprocRights()
      Specified by:
      hasFullIndexingDocprocRights in interface ImmutableSDField