Package com.yahoo.searchdefinition
Class RankProfile
- java.lang.Object
-
- com.yahoo.searchdefinition.RankProfile
-
- All Implemented Interfaces:
java.lang.Cloneable
- Direct Known Subclasses:
DefaultRankProfile
,DocumentsOnlyRankProfile
,UnrankedRankProfile
public class RankProfile extends java.lang.Object implements java.lang.Cloneable
Represents a rank profile - a named set of ranking settings- Author:
- bratseth
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RankProfile.DiversitySettings
static class
RankProfile.MatchPhaseSettings
static class
RankProfile.RankingExpressionFunction
A function in a rank profilestatic class
RankProfile.RankProperty
A rank property.static class
RankProfile.RankSetting
A rank setting.static class
RankProfile.TypeSettings
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<RankProfile.RankSetting>
rankSettings
The rank settings of this profile
-
Constructor Summary
Constructors Constructor Description RankProfile(java.lang.String name, Search search, RankProfileRegistry rankProfileRegistry)
Creates a new rank profile for a particular search definitionRankProfile(java.lang.String name, VespaModel model, RankProfileRegistry rankProfileRegistry)
Creates a global rank profile
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAttributeType(java.lang.String attributeName, java.lang.String attributeType)
void
addConstant(java.lang.String name, com.yahoo.searchlib.rankingexpression.evaluation.Value value)
void
addConstantTensor(java.lang.String name, com.yahoo.searchlib.rankingexpression.evaluation.TensorValue value)
RankProfile.RankingExpressionFunction
addFunction(com.yahoo.searchlib.rankingexpression.ExpressionFunction function, boolean inline)
Adds a function and returns itvoid
addFunction(java.lang.String name, java.util.List<java.lang.String> arguments, java.lang.String expression, boolean inline)
Adds a functionvoid
addQueryFeatureType(java.lang.String queryFeature, java.lang.String queryFeatureType)
void
addRankFeatures(com.yahoo.searchlib.rankingexpression.FeatureList features)
Adds the content of the given feature list to the internal list of rank features.void
addRankProperty(java.lang.String name, java.lang.String parameter)
void
addRankSetting(RankProfile.RankSetting rankSetting)
void
addRankSetting(java.lang.String fieldName, RankProfile.RankSetting.Type type, java.lang.Object value)
void
addSummaryFeatures(com.yahoo.searchlib.rankingexpression.FeatureList features)
Adds the content of the given feature list to the internal list of summary features.java.util.Set<java.lang.String>
allFilterFields()
Returns all filter fields in this profile and any profile it inherits.com.yahoo.config.application.api.ApplicationPackage
applicationPackage()
Returns the application this is part ofRankProfile
clone()
Shallow clones thisRankProfile
compile(com.yahoo.search.query.profile.QueryProfileRegistry queryProfiles, ai.vespa.rankingexpression.importer.configmodelview.ImportedMlModels importedModels)
Returns a copy of this where the content is optimized for execution.java.util.Iterator<RankProfile.RankSetting>
declaredRankSettingIterator()
Returns the rank settings in this rank profilejava.util.Set<java.lang.String>
filterFields()
RankProfile.RankingExpressionFunction
findFunction(java.lang.String name)
java.util.Map<java.lang.String,java.lang.String>
getAttributeTypes()
java.util.Map<java.lang.String,com.yahoo.searchlib.rankingexpression.evaluation.Value>
getConstants()
Returns an unmodifiable view of the constants available in thiscom.yahoo.searchlib.rankingexpression.RankingExpression
getFirstPhaseRanking()
Returns the ranking expression to use by this.java.util.Map<java.lang.String,RankProfile.RankingExpressionFunction>
getFunctions()
Returns an unmodifiable snapshot of the functions in thisboolean
getIgnoreDefaultRankFeatures()
RankProfile
getInherited()
Returns the inherited rank profile, or null if there is nonejava.lang.String
getInheritedName()
Returns the name of the profile this one inherits, or null if none is inheritedint
getKeepRankCount()
RankProfile.MatchPhaseSettings
getMatchPhaseSettings()
int
getMinHitsPerThread()
java.lang.String
getName()
int
getNumSearchPartitions()
int
getNumThreadsPerSearch()
java.util.Map<java.lang.String,java.lang.String>
getQueryFeatureTypes()
java.util.Set<com.yahoo.searchlib.rankingexpression.rule.ReferenceNode>
getRankFeatures()
Returns a read-only view of the rank features to use in this profile.java.util.List<RankProfile.RankProperty>
getRankProperties()
Returns a read only flattened list view of the rank properties to use in this profile.java.util.Map<java.lang.String,java.util.List<RankProfile.RankProperty>>
getRankPropertyMap()
Returns a read only map view of the rank properties to use in this profile.double
getRankScoreDropLimit()
RankProfile.RankSetting
getRankSetting(java.lang.String field, RankProfile.RankSetting.Type type)
Returns a rank setting of field or index, or null if there is no such rank setting in this profile or one it inheritsint
getRerankCount()
ImmutableSearch
getSearch()
Returns the search definition owning this, or null if it is globalcom.yahoo.searchlib.rankingexpression.RankingExpression
getSecondPhaseRanking()
Returns the ranking expression to use by this.java.util.Set<com.yahoo.searchlib.rankingexpression.rule.ReferenceNode>
getSummaryFeatures()
Returns a read-only view of the summary features to use in this profile.java.util.OptionalDouble
getTermwiseLimit()
boolean
inherits(java.lang.String name)
Returns whether this profile inherits (directly or indirectly) the given profileRankingConstants
rankingConstants()
Returns the ranking constants of the owner of thisjava.util.Iterator<RankProfile.RankSetting>
rankSettingIterator()
Returns all settings in this profile or any profile it inheritsjava.util.Set<RankProfile.RankSetting>
rankSettings()
Returns a snapshot of the rank settings of this and everything it inherits.void
setFirstPhaseRanking(java.lang.String expression)
void
setIgnoreDefaultRankFeatures(java.lang.Boolean ignoreDefaultRankFeatures)
Whether we should ignore the default rank features.void
setInherited(java.lang.String inheritedName)
Sets the name of the rank profile this inherits.void
setKeepRankCount(int rerankArraySize)
void
setMatchPhaseSettings(RankProfile.MatchPhaseSettings settings)
void
setMinHitsPerThread(int minHits)
void
setNumSearchPartitions(int numSearchPartitions)
void
setNumThreadsPerSearch(int numThreads)
void
setRankScoreDropLimit(double rankScoreDropLimit)
void
setRerankCount(int rerankCount)
Sets the rerank count.void
setSecondPhaseRanking(com.yahoo.searchlib.rankingexpression.RankingExpression rankingExpression)
void
setSecondPhaseRanking(java.lang.String expression)
void
setTermwiseLimit(double termwiseLimit)
java.lang.String
toString()
MapEvaluationTypeContext
typeContext(com.yahoo.search.query.profile.QueryProfileRegistry queryProfiles)
Creates a context containing the type information of all constants, attributes and query profiles referable from this rank profile.MapEvaluationTypeContext
typeContext(com.yahoo.search.query.profile.QueryProfileRegistry queryProfiles, java.util.Map<com.yahoo.searchlib.rankingexpression.Reference,com.yahoo.tensor.TensorType> featureTypes)
-
-
-
Field Detail
-
rankSettings
protected java.util.Set<RankProfile.RankSetting> rankSettings
The rank settings of this profile
-
-
Constructor Detail
-
RankProfile
public RankProfile(java.lang.String name, Search search, RankProfileRegistry rankProfileRegistry)
Creates a new rank profile for a particular search definition- Parameters:
name
- the name of the new profilesearch
- the search definition owning this profilerankProfileRegistry
- theRankProfileRegistry
to use for storing and looking up rank profiles.
-
RankProfile
public RankProfile(java.lang.String name, VespaModel model, RankProfileRegistry rankProfileRegistry)
Creates a global rank profile- Parameters:
name
- the name of the new profilemodel
- the model owning this profile
-
-
Method Detail
-
getName
public java.lang.String getName()
-
getSearch
public ImmutableSearch getSearch()
Returns the search definition owning this, or null if it is global
-
applicationPackage
public com.yahoo.config.application.api.ApplicationPackage applicationPackage()
Returns the application this is part of
-
rankingConstants
public RankingConstants rankingConstants()
Returns the ranking constants of the owner of this
-
setInherited
public void setInherited(java.lang.String inheritedName)
Sets the name of the rank profile this inherits. Both rank profiles must be present in the same search definition
-
getInheritedName
public java.lang.String getInheritedName()
Returns the name of the profile this one inherits, or null if none is inherited
-
getInherited
public RankProfile getInherited()
Returns the inherited rank profile, or null if there is none
-
inherits
public boolean inherits(java.lang.String name)
Returns whether this profile inherits (directly or indirectly) the given profile- Parameters:
name
- the profile name to compare this to.- Returns:
- whether or not this inherits from the named profile.
-
setMatchPhaseSettings
public void setMatchPhaseSettings(RankProfile.MatchPhaseSettings settings)
-
getMatchPhaseSettings
public RankProfile.MatchPhaseSettings getMatchPhaseSettings()
-
addRankSetting
public void addRankSetting(RankProfile.RankSetting rankSetting)
-
addRankSetting
public void addRankSetting(java.lang.String fieldName, RankProfile.RankSetting.Type type, java.lang.Object value)
-
getRankSetting
public RankProfile.RankSetting getRankSetting(java.lang.String field, RankProfile.RankSetting.Type type)
Returns a rank setting of field or index, or null if there is no such rank setting in this profile or one it inherits- Parameters:
field
- the field whose settings to returntype
- the type that the field is required to be- Returns:
- the rank setting found, or null
-
declaredRankSettingIterator
public java.util.Iterator<RankProfile.RankSetting> declaredRankSettingIterator()
Returns the rank settings in this rank profile- Returns:
- an iterator for the declared rank setting
-
rankSettingIterator
public java.util.Iterator<RankProfile.RankSetting> rankSettingIterator()
Returns all settings in this profile or any profile it inherits- Returns:
- an iterator for all rank settings of this
-
rankSettings
public java.util.Set<RankProfile.RankSetting> rankSettings()
Returns a snapshot of the rank settings of this and everything it inherits. Changes to the returned set will not be reflected in this rank profile.
-
addConstant
public void addConstant(java.lang.String name, com.yahoo.searchlib.rankingexpression.evaluation.Value value)
-
addConstantTensor
public void addConstantTensor(java.lang.String name, com.yahoo.searchlib.rankingexpression.evaluation.TensorValue value)
-
getConstants
public java.util.Map<java.lang.String,com.yahoo.searchlib.rankingexpression.evaluation.Value> getConstants()
Returns an unmodifiable view of the constants available in this
-
addAttributeType
public void addAttributeType(java.lang.String attributeName, java.lang.String attributeType)
-
getAttributeTypes
public java.util.Map<java.lang.String,java.lang.String> getAttributeTypes()
-
addQueryFeatureType
public void addQueryFeatureType(java.lang.String queryFeature, java.lang.String queryFeatureType)
-
getQueryFeatureTypes
public java.util.Map<java.lang.String,java.lang.String> getQueryFeatureTypes()
-
getFirstPhaseRanking
public com.yahoo.searchlib.rankingexpression.RankingExpression getFirstPhaseRanking()
Returns the ranking expression to use by this. This expression must not be edited. Returns null if no expression is set.
-
setFirstPhaseRanking
public void setFirstPhaseRanking(java.lang.String expression)
-
getSecondPhaseRanking
public com.yahoo.searchlib.rankingexpression.RankingExpression getSecondPhaseRanking()
Returns the ranking expression to use by this. This expression must not be edited. Returns null if no expression is set.
-
setSecondPhaseRanking
public void setSecondPhaseRanking(com.yahoo.searchlib.rankingexpression.RankingExpression rankingExpression)
-
setSecondPhaseRanking
public void setSecondPhaseRanking(java.lang.String expression)
-
getSummaryFeatures
public java.util.Set<com.yahoo.searchlib.rankingexpression.rule.ReferenceNode> getSummaryFeatures()
Returns a read-only view of the summary features to use in this profile. This is never null
-
addSummaryFeatures
public void addSummaryFeatures(com.yahoo.searchlib.rankingexpression.FeatureList features)
Adds the content of the given feature list to the internal list of summary features.- Parameters:
features
- The features to add.
-
getRankFeatures
public java.util.Set<com.yahoo.searchlib.rankingexpression.rule.ReferenceNode> getRankFeatures()
Returns a read-only view of the rank features to use in this profile. This is never null
-
addRankFeatures
public void addRankFeatures(com.yahoo.searchlib.rankingexpression.FeatureList features)
Adds the content of the given feature list to the internal list of rank features.- Parameters:
features
- The features to add.
-
getRankProperties
public java.util.List<RankProfile.RankProperty> getRankProperties()
Returns a read only flattened list view of the rank properties to use in this profile. This is never null.
-
getRankPropertyMap
public java.util.Map<java.lang.String,java.util.List<RankProfile.RankProperty>> getRankPropertyMap()
Returns a read only map view of the rank properties to use in this profile. This is never null.
-
addRankProperty
public void addRankProperty(java.lang.String name, java.lang.String parameter)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getRerankCount
public int getRerankCount()
-
getNumThreadsPerSearch
public int getNumThreadsPerSearch()
-
setNumThreadsPerSearch
public void setNumThreadsPerSearch(int numThreads)
-
getMinHitsPerThread
public int getMinHitsPerThread()
-
setMinHitsPerThread
public void setMinHitsPerThread(int minHits)
-
setNumSearchPartitions
public void setNumSearchPartitions(int numSearchPartitions)
-
getNumSearchPartitions
public int getNumSearchPartitions()
-
getTermwiseLimit
public java.util.OptionalDouble getTermwiseLimit()
-
setTermwiseLimit
public void setTermwiseLimit(double termwiseLimit)
-
setRerankCount
public void setRerankCount(int rerankCount)
Sets the rerank count. Set to -1 to use inherited
-
setIgnoreDefaultRankFeatures
public void setIgnoreDefaultRankFeatures(java.lang.Boolean ignoreDefaultRankFeatures)
Whether we should ignore the default rank features. Set to null to use inherited
-
getIgnoreDefaultRankFeatures
public boolean getIgnoreDefaultRankFeatures()
-
addFunction
public void addFunction(java.lang.String name, java.util.List<java.lang.String> arguments, java.lang.String expression, boolean inline)
Adds a function
-
addFunction
public RankProfile.RankingExpressionFunction addFunction(com.yahoo.searchlib.rankingexpression.ExpressionFunction function, boolean inline)
Adds a function and returns it
-
findFunction
public RankProfile.RankingExpressionFunction findFunction(java.lang.String name)
-
getFunctions
public java.util.Map<java.lang.String,RankProfile.RankingExpressionFunction> getFunctions()
Returns an unmodifiable snapshot of the functions in this
-
getKeepRankCount
public int getKeepRankCount()
-
setKeepRankCount
public void setKeepRankCount(int rerankArraySize)
-
getRankScoreDropLimit
public double getRankScoreDropLimit()
-
setRankScoreDropLimit
public void setRankScoreDropLimit(double rankScoreDropLimit)
-
filterFields
public java.util.Set<java.lang.String> filterFields()
-
allFilterFields
public java.util.Set<java.lang.String> allFilterFields()
Returns all filter fields in this profile and any profile it inherits.- Returns:
- the set of all filter fields
-
clone
public RankProfile clone()
Shallow clones this- Overrides:
clone
in classjava.lang.Object
-
compile
public RankProfile compile(com.yahoo.search.query.profile.QueryProfileRegistry queryProfiles, ai.vespa.rankingexpression.importer.configmodelview.ImportedMlModels importedModels)
Returns a copy of this where the content is optimized for execution. Compiled profiles should never be modified.
-
typeContext
public MapEvaluationTypeContext typeContext(com.yahoo.search.query.profile.QueryProfileRegistry queryProfiles)
Creates a context containing the type information of all constants, attributes and query profiles referable from this rank profile.
-
typeContext
public MapEvaluationTypeContext typeContext(com.yahoo.search.query.profile.QueryProfileRegistry queryProfiles, java.util.Map<com.yahoo.searchlib.rankingexpression.Reference,com.yahoo.tensor.TensorType> featureTypes)
-
-