Class SDField
- java.lang.Object
-
- com.yahoo.vespa.objects.FieldBase
-
- com.yahoo.document.Field
-
- com.yahoo.searchdefinition.document.SDField
-
- All Implemented Interfaces:
com.yahoo.document.fieldset.FieldSet
,ImmutableSDField
,TypedKey
,FieldOperationContainer
,java.io.Serializable
,java.lang.Comparable
- Direct Known Subclasses:
TemporarySDField
public class SDField extends com.yahoo.document.Field implements TypedKey, FieldOperationContainer, 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
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description SDField(SDDocumentType repo, java.lang.String name, int id, com.yahoo.document.DataType dataType)
protected
SDField(SDDocumentType repo, java.lang.String name, int id, com.yahoo.document.DataType dataType, boolean populate)
Creates a new field.SDField(SDDocumentType repo, java.lang.String name, com.yahoo.document.DataType dataType)
SDField(SDDocumentType repo, java.lang.String name, com.yahoo.document.DataType dataType, boolean populate)
Creates a new field.protected
SDField(SDDocumentType repo, java.lang.String name, com.yahoo.document.DataType dataType, SDDocumentType owner, boolean populate)
Creates a new field.protected
SDField(SDDocumentType repo, java.lang.String name, com.yahoo.document.DataType dataType, SDDocumentType owner, Matching fieldMatching, boolean populate, int recursion)
Creates a new field.SDField(java.lang.String name, com.yahoo.document.DataType dataType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAttribute(Attribute attribute)
void
addIndex(Index index)
Adds an explicit index defined in this fieldvoid
addOperation(FieldOperation op)
Adds an operationvoid
addQueryCommand(java.lang.String name)
void
addSummaryField(SummaryField summaryField)
Adds a summary fieldvoid
addSummaryFieldSources(SummaryField summaryField)
void
applyOperations()
void
applyOperations(SDField field)
Apply all operations.com.yahoo.document.Field
asField()
Returns aField
representation (which is sadly not immutable)<T extends com.yahoo.vespa.indexinglanguage.expressions.Expression>
booleancontainsExpression(java.lang.Class<T> searchFor)
boolean
doesAttributing()
boolean
doesIndexing()
boolean
doesLowerCasing()
boolean
doesSummarying()
boolean
equals(java.lang.Object other)
boolean
existsIndex(java.lang.String name)
Returns an index if this field has one (implicitly or explicitly) targeting the given name.java.util.Map<java.lang.String,java.lang.String>
getAliasToName()
The aliases declared for this fieldAttribute
getAttribute()
java.util.Map<java.lang.String,Attribute>
getAttributes()
Returns the search-time attribute settings of this field or null if none is set.com.yahoo.document.StructDataType
getFirstStructRecursive()
Index
getIndex(java.lang.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)com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression
getIndexingScript()
java.util.Map<java.lang.String,Index>
getIndices()
Defined indices on this fieldint
getLiteralBoost()
Returns the literal boost of this field.Matching
getMatching()
Returns what kind of matching type should be applied.NormalizeLevel
getNormalizing()
Returns how the content of this field should be accent normalized etcjava.util.List<java.lang.String>
getQueryCommands()
Returns a list of query commandsRanking
getRanking()
Returns the rank settings set in a "rank" block for this field.RankType
getRankType()
Returns the default rank type of indices of this field, or null if nothing is setStemming
getStemming()
Returns the stemming setting of this field.Stemming
getStemming(Search search)
Whether this field should be stemmed in this search definitionSDField
getStructField(java.lang.String name)
Returns a struct field defined in this field, potentially traversing into nested structs.java.util.Collection<SDField>
getStructFields()
Returns list of static struct fieldsSummaryField
getSummaryField(java.lang.String name)
Returns a summary field defined (implicitly or explicitly) by this field.SummaryField
getSummaryField(java.lang.String name, boolean create)
Returns a summary field defined (implicitly or explicitly) by this field.java.util.Map<java.lang.String,SummaryField>
getSummaryFields()
Returns an unmodifiable map of the summary fields defined in thisint
getWeight()
Returns the weight of this field, or 0 if nothing is setboolean
hasFullIndexingDocprocRights()
int
hashCode()
boolean
hasIndex()
boolean
hasQueryCommand(java.lang.String name)
boolean
isExtraField()
boolean
isImportedField()
boolean
isIndexStructureField()
void
parseIndexingScript(java.lang.String script)
Parse an indexing expression which will use the simple linguistics implementatino suitable for testingvoid
parseIndexingScript(java.lang.String script, com.yahoo.language.Linguistics linguistics)
void
populateWithStructFields(SDDocumentType sdoc, java.lang.String name, com.yahoo.document.DataType dataType, int recursion)
void
populateWithStructMatching(SDDocumentType sdoc, java.lang.String name, com.yahoo.document.DataType dataType, Matching superFieldMatching)
void
removeSummaryFields()
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(Matching.Algorithm algorithm)
Set matching algorithm for this field and all subfields.void
setMatchingType(Matching.Type 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 fieldjava.lang.String
toString()
boolean
usesStructOrMap()
-
Methods inherited from class com.yahoo.document.Field
calculateIdV7, clone, compareTo, contains, getDataType, getId, getId, hasForcedId, isHeader, setHeader
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.yahoo.searchdefinition.fieldoperation.FieldOperationContainer
getName
-
Methods inherited from interface com.yahoo.searchdefinition.document.ImmutableSDField
getDataType, getName
-
Methods inherited from interface com.yahoo.searchdefinition.document.TypedKey
getDataType, getName
-
-
-
-
Constructor Detail
-
SDField
protected SDField(SDDocumentType repo, java.lang.String name, int id, com.yahoo.document.DataType dataType, boolean populate)
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
public SDField(SDDocumentType repo, java.lang.String name, int id, com.yahoo.document.DataType dataType)
-
SDField
public SDField(SDDocumentType repo, java.lang.String name, com.yahoo.document.DataType dataType, boolean populate)
Creates a new field.- Parameters:
name
- The name of the fielddataType
- The datatype of the field
-
SDField
protected SDField(SDDocumentType repo, java.lang.String name, com.yahoo.document.DataType dataType, SDDocumentType owner, boolean populate)
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)
-
SDField
protected SDField(SDDocumentType repo, java.lang.String name, com.yahoo.document.DataType dataType, SDDocumentType owner, Matching fieldMatching, boolean populate, 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
-
SDField
public SDField(SDDocumentType repo, java.lang.String name, com.yahoo.document.DataType dataType)
- Parameters:
name
- The name of the fielddataType
- The datatype of the field
-
SDField
public SDField(java.lang.String name, com.yahoo.document.DataType dataType)
-
-
Method Detail
-
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(java.lang.Class<T> searchFor)
- Specified by:
containsExpression
in interfaceImmutableSDField
-
addSummaryFieldSources
public void addSummaryFieldSources(SummaryField summaryField)
-
populateWithStructFields
public void populateWithStructFields(SDDocumentType sdoc, java.lang.String name, com.yahoo.document.DataType dataType, int recursion)
-
populateWithStructMatching
public void populateWithStructMatching(SDDocumentType sdoc, java.lang.String name, com.yahoo.document.DataType dataType, Matching superFieldMatching)
-
addOperation
public void addOperation(FieldOperation op)
Description copied from interface:FieldOperationContainer
Adds an operation- Specified by:
addOperation
in interfaceFieldOperationContainer
-
applyOperations
public void applyOperations(SDField field)
Description copied from interface:FieldOperationContainer
Apply all operations. Operations must be sorted in their natural order before applying each operation.- Specified by:
applyOperations
in interfaceFieldOperationContainer
-
applyOperations
public void applyOperations()
-
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
-
parseIndexingScript
public void parseIndexingScript(java.lang.String script)
Parse an indexing expression which will use the simple linguistics implementatino suitable for testing
-
parseIndexingScript
public void parseIndexingScript(java.lang.String script, com.yahoo.language.Linguistics linguistics)
-
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
public Matching getMatching()
Returns what kind of matching type should be applied.- Specified by:
getMatching
in interfaceImmutableSDField
-
setMatching
public void setMatching(Matching matching)
Sets what kind of matching type should be applied. (Token matching is default, PREFIX, SUBSTRING, SUFFIX are alternatives)
-
setMatchingType
public void setMatchingType(Matching.Type type)
Set the matching type for this field and all subfields.
-
setMatchingAlgorithm
public void setMatchingAlgorithm(Matching.Algorithm 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(java.lang.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 interfaceImmutableSDField
-
existsIndex
public boolean existsIndex(java.lang.String name)
Returns an index if this field has one (implicitly or explicitly) targeting the given name.- Specified by:
existsIndex
in interfaceImmutableSDField
-
getIndices
public java.util.Map<java.lang.String,Index> getIndices()
Defined indices on this field- Specified by:
getIndices
in interfaceImmutableSDField
- 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 interfaceImmutableSDField
-
getRankType
public RankType getRankType()
Returns the default rank type of indices of this field, or null if nothing is set- Specified by:
getRankType
in interfaceImmutableSDField
-
getAttributes
public java.util.Map<java.lang.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 interfaceImmutableSDField
-
getAttribute
public Attribute getAttribute()
- Specified by:
getAttribute
in interfaceImmutableSDField
-
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 interfaceImmutableSDField
- Returns:
- the stemming setting of this, or null, to use the default
-
getStemming
public Stemming getStemming(Search search)
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
public void setStemming(Stemming stemming)
Sets how this field should be stemmed, or set to null to use the default.
-
getSummaryFields
public java.util.Map<java.lang.String,SummaryField> getSummaryFields()
Returns an unmodifiable map of the summary fields defined in this- Specified by:
getSummaryFields
in interfaceImmutableSDField
-
removeSummaryFields
public void removeSummaryFields()
-
addSummaryField
public void addSummaryField(SummaryField summaryField)
Adds a summary field
-
getSummaryField
public SummaryField getSummaryField(java.lang.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 interfaceImmutableSDField
-
getSummaryField
public SummaryField getSummaryField(java.lang.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 java.util.Collection<SDField> getStructFields()
Returns list of static struct fields- Specified by:
getStructFields
in interfaceImmutableSDField
-
getStructField
public SDField getStructField(java.lang.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 interfaceImmutableSDField
-
getNormalizing
public NormalizeLevel getNormalizing()
Returns how the content of this field should be accent normalized etc- Specified by:
getNormalizing
in interfaceImmutableSDField
-
setNormalizing
public void setNormalizing(NormalizeLevel level)
Change how the content of this field should be accent normalized etc
-
addQueryCommand
public void addQueryCommand(java.lang.String name)
-
hasQueryCommand
public boolean hasQueryCommand(java.lang.String name)
-
getQueryCommands
public java.util.List<java.lang.String> getQueryCommands()
Returns a list of query commands- Specified by:
getQueryCommands
in interfaceImmutableSDField
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classcom.yahoo.document.Field
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classcom.yahoo.document.Field
-
toString
public java.lang.String toString()
- Overrides:
toString
in classcom.yahoo.document.Field
-
getAliasToName
public java.util.Map<java.lang.String,java.lang.String> getAliasToName()
The aliases declared for this field- Specified by:
getAliasToName
in interfaceImmutableSDField
-
hasFullIndexingDocprocRights
public boolean hasFullIndexingDocprocRights()
- Specified by:
hasFullIndexingDocprocRights
in interfaceImmutableSDField
-
-