Package com.yahoo.schema.document
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
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
-
Field Summary
Fields inherited from class com.yahoo.document.Field
dataType, fieldId
-
Constructor Summary
ModifierConstructorDescriptionSDField
(SDDocumentType repo, String name, int id, com.yahoo.document.DataType dataType) Creates a new field.SDField
(SDDocumentType repo, String name, com.yahoo.document.DataType dataType) Creates a new fieldprotected
SDField
(SDDocumentType repo, String name, com.yahoo.document.DataType dataType, SDDocumentType owner) Creates a new fieldprotected
SDField
(SDDocumentType repo, String name, com.yahoo.document.DataType dataType, SDDocumentType owner, Matching fieldMatching, int recursion) Creates a new field -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAttribute
(Attribute attribute) void
Adds an explicit index defined in this fieldvoid
addQueryCommand
(String name) void
addSummaryField
(SummaryField summaryField) Adds a summary fieldvoid
addSummaryFieldSources
(SummaryField summaryField) com.yahoo.document.Field
asField()
Returns aField
representation (which is sadly not immutable)<T extends com.yahoo.vespa.indexinglanguage.expressions.Expression>
booleancontainsExpression
(Class<T> searchFor) boolean
boolean
boolean
boolean
boolean
boolean
existsIndex
(String name) Returns an index if this field has one (implicitly or explicitly) targeting the given name.The aliases declared for this fieldReturns the search-time attribute settings of this field or null if none is set.Returns Dictionary settings.com.yahoo.document.StructDataType
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)com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression
Defined indices on this fieldint
Returns the literal boost of this field.Returns what kind of matching type should be applied.Returns how the content of this field should be accent normalized etcReturns a list of query commandsReturns the rank settings set in a "rank" block for this field.Returns the default rank type of indices of this field, or null if nothing is setReturns the stemming setting of this field.getStemming
(Schema schema) Whether this field should be stemmed in this search definitiongetStructField
(String name) Returns a struct field defined in this field, potentially traversing into nested structs.Returns list of static struct fieldsgetSummaryField
(String name) Returns a summary field defined (implicitly or explicitly) by this field.getSummaryField
(String name, boolean create) Returns a summary field defined (implicitly or explicitly) by this field.Returns an unmodifiable map of the summary fields defined in thisint
Returns the weight of this field, or 0 if nothing is setboolean
int
hashCode()
boolean
hasIndex()
boolean
hasQueryCommand
(String name) boolean
Returns whether this field has a single attribute with the same name as this field.boolean
boolean
boolean
void
parseIndexingScript
(String script) Parse an indexing expression which will use the simple linguistics implementation suitable for testingvoid
parseIndexingScript
(String script, com.yahoo.language.Linguistics linguistics, Map<String, com.yahoo.language.process.Embedder> embedders) void
void
setDataType
(com.yahoo.document.DataType type) void
setId
(int fieldId, com.yahoo.document.DocumentType owner) void
setIndexingScript
(com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression exp) Sets the indexing script of this, or null to not use a scriptvoid
setIndexStructureField
(boolean indexStructureField) void
setIsExtraField
(boolean isExtra) void
setLiteralBoost
(int literalBoost) Sets the literal boost of this fieldvoid
setMatching
(Matching matching) Sets what kind of matching type should be applied.void
setMatchingAlgorithm
(MatchAlgorithm algorithm) Set matching algorithm for this field and all subfields.void
setMatchingCase
(Case casing) Set the matching type for this field and all subfields.void
setMatchingType
(MatchType type) Set the matching type for this field and all subfields.void
setNormalizing
(NormalizeLevel level) Change how the content of this field should be accent normalized etcvoid
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.void
setStemming
(Stemming stemming) Sets how this field should be stemmed, or set to null to use the default.void
setWeight
(int weight) Sets the weight of this fieldtoString()
boolean
boolean
Whether this field at some time was configured to do attributing.boolean
Whether this field at some time was configured to do indexing.Methods inherited from class com.yahoo.document.Field
calculateIdV7, clone, compareTo, contains, getDataType, getId, hasForcedId
Methods inherited from class com.yahoo.vespa.objects.FieldBase
getName
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.yahoo.schema.document.ImmutableSDField
getDataType, getName
Methods inherited from interface com.yahoo.schema.document.TypedKey
getDataType, getName
-
Constructor Details
-
SDField
Creates a new field. This method is only used to create reserved fields.- Parameters:
name
- the name of the fielddataType
- the datatype of the field
-
SDField
-
SDField
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 fielddataType
- the datatype of the fieldowner
- 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 interfaceImmutableSDField
-
isImportedField
public boolean isImportedField()- Specified by:
isImportedField
in interfaceImmutableSDField
-
doesAttributing
public boolean doesAttributing()- Specified by:
doesAttributing
in interfaceImmutableSDField
-
doesIndexing
public boolean doesIndexing()- Specified by:
doesIndexing
in interfaceImmutableSDField
-
doesSummarying
public boolean doesSummarying() -
doesLowerCasing
public boolean doesLowerCasing()- Specified by:
doesLowerCasing
in interfaceImmutableSDField
-
containsExpression
public <T extends com.yahoo.vespa.indexinglanguage.expressions.Expression> boolean containsExpression(Class<T> searchFor) - Specified by:
containsExpression
in interfaceImmutableSDField
-
addSummaryFieldSources
-
setId
public void setId(int fieldId, com.yahoo.document.DocumentType owner) - Overrides:
setId
in classcom.yahoo.document.Field
-
getFirstStructRecursive
public com.yahoo.document.StructDataType getFirstStructRecursive() -
usesStructOrMap
public boolean usesStructOrMap()- Specified by:
usesStructOrMap
in interfaceImmutableSDField
-
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 interfaceImmutableSDField
-
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 interfaceImmutableSDField
-
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 interfaceImmutableSDField
-
parseIndexingScript
Parse an indexing expression which will use the simple linguistics implementation suitable for testing -
parseIndexingScript
-
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 interfaceImmutableSDField
-
setDataType
public void setDataType(com.yahoo.document.DataType type) - Specified by:
setDataType
in interfaceTypedKey
- Overrides:
setDataType
in classcom.yahoo.document.Field
-
isIndexStructureField
public boolean isIndexStructureField()- Specified by:
isIndexStructureField
in interfaceImmutableSDField
-
setIndexStructureField
public void setIndexStructureField(boolean indexStructureField) -
hasIndex
public boolean hasIndex()- Specified by:
hasIndex
in interfaceImmutableSDField
-
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 interfaceImmutableSDField
-
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 interfaceImmutableSDField
-
getMatching
Returns what kind of matching type should be applied.- Specified by:
getMatching
in interfaceImmutableSDField
-
setMatching
Sets what kind of matching type should be applied. (Token matching is default, PREFIX, SUBSTRING, SUFFIX are alternatives) -
getDictionary
Returns Dictionary settings. -
getOrSetDictionary
-
setMatchingType
Set the matching type for this field and all subfields. -
setMatchingCase
Set the matching type for this field and all subfields. -
setMatchingAlgorithm
Set matching algorithm for this field and all subfields. -
addIndex
Adds an explicit index defined in this field -
getIndex
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 interfaceImmutableSDField
-
existsIndex
Returns an index if this field has one (implicitly or explicitly) targeting the given name.- Specified by:
existsIndex
in interfaceImmutableSDField
-
getIndices
Defined indices on this field- Specified by:
getIndices
in interfaceImmutableSDField
- Returns:
- defined indices on this
-
setRankType
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
Returns the rank settings set in a "rank" block for this field. This is never null.- Specified by:
getRanking
in interfaceImmutableSDField
-
getRankType
Returns the default rank type of indices of this field, or null if nothing is set- Specified by:
getRankType
in interfaceImmutableSDField
-
getAttributes
Returns the search-time attribute settings of this field or null if none is set.TODO: Make unmodifiable.
- Specified by:
getAttributes
in interfaceImmutableSDField
-
getAttribute
- Specified by:
getAttribute
in interfaceImmutableSDField
-
addAttribute
-
getStemming
Returns the stemming setting of this field. Default is determined by the owning search definition.- Specified by:
getStemming
in interfaceImmutableSDField
- Returns:
- the stemming setting of this, or null, to use the default
-
getStemming
Whether this field should be stemmed in this search definition- Specified by:
getStemming
in interfaceImmutableSDField
-
asField
public com.yahoo.document.Field asField()Description copied from interface:ImmutableSDField
Returns aField
representation (which is sadly not immutable)- Specified by:
asField
in interfaceImmutableSDField
-
setStemming
Sets how this field should be stemmed, or set to null to use the default. -
getSummaryFields
Returns an unmodifiable map of the summary fields defined in this- Specified by:
getSummaryFields
in interfaceImmutableSDField
-
removeSummaryFields
public void removeSummaryFields() -
addSummaryField
Adds a summary field -
getSummaryField
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 interfaceImmutableSDField
-
getSummaryField
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
Returns list of static struct fields- Specified by:
getStructFields
in interfaceImmutableSDField
-
getStructField
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 interfaceImmutableSDField
-
getNormalizing
Returns how the content of this field should be accent normalized etc- Specified by:
getNormalizing
in interfaceImmutableSDField
-
setNormalizing
Change how the content of this field should be accent normalized etc -
addQueryCommand
-
hasQueryCommand
-
getQueryCommands
Returns a list of query commands- Specified by:
getQueryCommands
in interfaceImmutableSDField
-
equals
- Overrides:
equals
in classcom.yahoo.document.Field
-
hashCode
public int hashCode()- Overrides:
hashCode
in classcom.yahoo.document.Field
-
toString
- Overrides:
toString
in classcom.yahoo.document.Field
-
getAliasToName
The aliases declared for this field- Specified by:
getAliasToName
in interfaceImmutableSDField
-
hasFullIndexingDocprocRights
public boolean hasFullIndexingDocprocRights()- Specified by:
hasFullIndexingDocprocRights
in interfaceImmutableSDField
-