Package com.yahoo.searchdefinition
Class RankProfile
- java.lang.Object
-
- com.yahoo.searchdefinition.RankProfile
-
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
DefaultRankProfile
,DocumentsOnlyRankProfile
,UnrankedRankProfile
public class RankProfile extends Object implements 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.MutateOperation
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 static String
FIRST_PHASE
protected Set<RankProfile.RankSetting>
rankSettings
The rank settings of this profilestatic String
SECOND_PHASE
-
Constructor Summary
Constructors Constructor Description RankProfile(String name, com.yahoo.config.application.api.ApplicationPackage applicationPackage, com.yahoo.config.application.api.DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, RankingConstants rankingConstants, OnnxModels onnxModels)
Creates a global rank profileRankProfile(String name, Schema schema, RankProfileRegistry rankProfileRegistry, RankingConstants rankingConstants)
Creates a new rank profile for a particular search definition
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAttributeType(String attributeName, String attributeType)
void
addConstant(String name, com.yahoo.searchlib.rankingexpression.evaluation.Value value)
void
addConstantTensor(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(String name, List<String> arguments, String expression, boolean inline)
void
addInputFeature(String name, com.yahoo.tensor.TensorType declaredType)
Use for rank profiles representing a model evaluation; it will assume that a input is provided with the declared type (for the purpose of type resolving).void
addMatchFeatures(com.yahoo.searchlib.rankingexpression.FeatureList features)
Adds the content of the given feature list to the internal list of match features.void
addMutateOperation(RankProfile.MutateOperation.Phase phase, String attribute, String operation)
void
addQueryFeatureType(String queryFeature, 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(String name, String parameter)
void
addRankSetting(RankProfile.RankSetting rankSetting)
void
addRankSetting(String fieldName, RankProfile.RankSetting.Type type, 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.Set<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.Iterator<RankProfile.RankSetting>
declaredRankSettingIterator()
Returns the rank settings in this rank profileSet<String>
filterFields()
RankProfile.RankingExpressionFunction
findFunction(String name)
Map<String,String>
getAttributeTypes()
Map<String,com.yahoo.searchlib.rankingexpression.evaluation.Value>
getConstants()
Returns an unmodifiable view of the constants available in thisRankProfile.RankingExpressionFunction
getFirstPhase()
com.yahoo.searchlib.rankingexpression.RankingExpression
getFirstPhaseRanking()
Returns the ranking expression to use by this.Map<String,RankProfile.RankingExpressionFunction>
getFunctions()
Returns an unmodifiable snapshot of the functions in thisboolean
getIgnoreDefaultRankFeatures()
int
getKeepRankCount()
Set<com.yahoo.searchlib.rankingexpression.rule.ReferenceNode>
getMatchFeatures()
Returns a read-only view of the match features to use in this profile.RankProfile.MatchPhaseSettings
getMatchPhaseSettings()
int
getMinHitsPerThread()
List<RankProfile.MutateOperation>
getMutateOperations()
int
getNumSearchPartitions()
int
getNumThreadsPerSearch()
Map<String,String>
getQueryFeatureTypes()
Set<com.yahoo.searchlib.rankingexpression.rule.ReferenceNode>
getRankFeatures()
Returns a read-only view of the rank features to use in this profile.List<RankProfile.RankProperty>
getRankProperties()
Returns a read only flattened list view of the rank properties to use in this profile.Map<String,List<RankProfile.RankProperty>>
getRankPropertyMap()
Returns a read only map view of the rank properties to use in this profile.double
getRankScoreDropLimit()
RankProfile.RankSetting
getRankSetting(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()
RankProfile.RankingExpressionFunction
getSecondPhase()
com.yahoo.searchlib.rankingexpression.RankingExpression
getSecondPhaseRanking()
Returns the ranking expression to use by this.Set<com.yahoo.searchlib.rankingexpression.rule.ReferenceNode>
getSummaryFeatures()
Returns a read-only view of the summary features to use in this profile.OptionalDouble
getTermwiseLimit()
void
inherit(String inheritedName)
Adds a profile to those inherited by this.List<String>
inheritedNames()
Returns the names of the profiles this inherits, if any.boolean
inherits(String name)
Returns whether this profile inherits (directly or indirectly) the given profile name.String
name()
Map<String,OnnxModel>
onnxModels()
RankingConstants
rankingConstants()
Returns the ranking constants of the owner of thisIterator<RankProfile.RankSetting>
rankSettingIterator()
Returns all settings in this profile or any profile it inheritsSet<RankProfile.RankSetting>
rankSettings()
Returns a snapshot of the rank settings of this and everything it inherits.ImmutableSchema
schema()
Returns the search definition owning this, or null if it is globalvoid
setFirstPhaseRanking(String expression)
void
setIgnoreDefaultRankFeatures(Boolean ignoreDefaultRankFeatures)
Whether we should ignore the default rank features.void
setInheritedMatchFeatures(String parentProfile)
Sets the name of a profile this should inherit the match features of.void
setInheritedSummaryFeatures(String parentProfile)
Sets the name this should inherit the summary features of.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)
void
setSecondPhaseRanking(String expression)
void
setTermwiseLimit(double termwiseLimit)
String
toString()
MapEvaluationTypeContext
typeContext()
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, Map<com.yahoo.searchlib.rankingexpression.Reference,com.yahoo.tensor.TensorType> featureTypes)
-
-
-
Field Detail
-
FIRST_PHASE
public static final String FIRST_PHASE
- See Also:
- Constant Field Values
-
SECOND_PHASE
public static final String SECOND_PHASE
- See Also:
- Constant Field Values
-
rankSettings
protected Set<RankProfile.RankSetting> rankSettings
The rank settings of this profile
-
-
Constructor Detail
-
RankProfile
public RankProfile(String name, Schema schema, RankProfileRegistry rankProfileRegistry, RankingConstants rankingConstants)
Creates a new rank profile for a particular search definition- Parameters:
name
- the name of the new profileschema
- the search definition owning this profilerankProfileRegistry
- theRankProfileRegistry
to use for storing and looking up rank profiles.
-
RankProfile
public RankProfile(String name, com.yahoo.config.application.api.ApplicationPackage applicationPackage, com.yahoo.config.application.api.DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, RankingConstants rankingConstants, OnnxModels onnxModels)
Creates a global rank profile- Parameters:
name
- the name of the new profile
-
-
Method Detail
-
name
public String name()
-
schema
public ImmutableSchema schema()
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
-
inherit
public void inherit(String inheritedName)
Adds a profile to those inherited by this. The profile must belong to this schema (directly or by inheritance).
-
inheritedNames
public List<String> inheritedNames()
Returns the names of the profiles this inherits, if any.
-
inherits
public boolean inherits(String name)
Returns whether this profile inherits (directly or indirectly) the given profile name.
-
setMatchPhaseSettings
public void setMatchPhaseSettings(RankProfile.MatchPhaseSettings settings)
-
getMatchPhaseSettings
public RankProfile.MatchPhaseSettings getMatchPhaseSettings()
-
addRankSetting
public void addRankSetting(RankProfile.RankSetting rankSetting)
-
addRankSetting
public void addRankSetting(String fieldName, RankProfile.RankSetting.Type type, Object value)
-
getRankSetting
public RankProfile.RankSetting getRankSetting(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 Iterator<RankProfile.RankSetting> declaredRankSettingIterator()
Returns the rank settings in this rank profile- Returns:
- an iterator for the declared rank setting
-
rankSettingIterator
public 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 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(String name, com.yahoo.searchlib.rankingexpression.evaluation.Value value)
-
addConstantTensor
public void addConstantTensor(String name, com.yahoo.searchlib.rankingexpression.evaluation.TensorValue value)
-
getConstants
public Map<String,com.yahoo.searchlib.rankingexpression.evaluation.Value> getConstants()
Returns an unmodifiable view of the constants available in this
-
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.
-
getFirstPhase
public RankProfile.RankingExpressionFunction getFirstPhase()
-
setFirstPhaseRanking
public void setFirstPhaseRanking(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.
-
getSecondPhase
public RankProfile.RankingExpressionFunction getSecondPhase()
-
setSecondPhaseRanking
public void setSecondPhaseRanking(String expression)
-
setInheritedSummaryFeatures
public void setInheritedSummaryFeatures(String parentProfile)
Sets the name this should inherit the summary features of. Without setting this, this will either have the summary features of the single parent setting them, or if summary features are set in this, only have the summary features in this. With this set the resulting summary features of this will be the superset of those defined in this and the final (with inheritance included) summary features of the given parent. The profile must be one which is directly inherited by this.
-
setInheritedMatchFeatures
public void setInheritedMatchFeatures(String parentProfile)
Sets the name of a profile this should inherit the match features of. Without setting this, this will either have the match features of the single parent setting them, or if match features are set in this, only have the match features in this. With this set the resulting match features of this will be the superset of those defined in this and the final (with inheritance included) match features of the given parent. The profile must be one which which is directly inherited by this.
-
getSummaryFeatures
public 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
-
getMatchFeatures
public Set<com.yahoo.searchlib.rankingexpression.rule.ReferenceNode> getMatchFeatures()
Returns a read-only view of the match 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.
-
addMatchFeatures
public void addMatchFeatures(com.yahoo.searchlib.rankingexpression.FeatureList features)
Adds the content of the given feature list to the internal list of match features.
-
getRankFeatures
public 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 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 Map<String,List<RankProfile.RankProperty>> getRankPropertyMap()
Returns a read only map view of the rank properties to use in this profile. This is never null.
-
setRerankCount
public void setRerankCount(int rerankCount)
-
getRerankCount
public int getRerankCount()
-
setNumThreadsPerSearch
public void setNumThreadsPerSearch(int numThreads)
-
getNumThreadsPerSearch
public int getNumThreadsPerSearch()
-
setMinHitsPerThread
public void setMinHitsPerThread(int minHits)
-
getMinHitsPerThread
public int getMinHitsPerThread()
-
setNumSearchPartitions
public void setNumSearchPartitions(int numSearchPartitions)
-
getNumSearchPartitions
public int getNumSearchPartitions()
-
setTermwiseLimit
public void setTermwiseLimit(double termwiseLimit)
-
getTermwiseLimit
public OptionalDouble getTermwiseLimit()
-
setIgnoreDefaultRankFeatures
public void setIgnoreDefaultRankFeatures(Boolean ignoreDefaultRankFeatures)
Whether we should ignore the default rank features. Set to null to use inherited
-
getIgnoreDefaultRankFeatures
public boolean getIgnoreDefaultRankFeatures()
-
setKeepRankCount
public void setKeepRankCount(int rerankArraySize)
-
getKeepRankCount
public int getKeepRankCount()
-
setRankScoreDropLimit
public void setRankScoreDropLimit(double rankScoreDropLimit)
-
getRankScoreDropLimit
public double getRankScoreDropLimit()
-
addFunction
public void addFunction(String name, List<String> arguments, String expression, boolean inline)
-
addFunction
public RankProfile.RankingExpressionFunction addFunction(com.yahoo.searchlib.rankingexpression.ExpressionFunction function, boolean inline)
Adds a function and returns it
-
addInputFeature
public void addInputFeature(String name, com.yahoo.tensor.TensorType declaredType)
Use for rank profiles representing a model evaluation; it will assume that a input is provided with the declared type (for the purpose of type resolving).
-
addMutateOperation
public void addMutateOperation(RankProfile.MutateOperation.Phase phase, String attribute, String operation)
-
getMutateOperations
public List<RankProfile.MutateOperation> getMutateOperations()
-
findFunction
public RankProfile.RankingExpressionFunction findFunction(String name)
-
getFunctions
public Map<String,RankProfile.RankingExpressionFunction> getFunctions()
Returns an unmodifiable snapshot of the functions in this
-
allFilterFields
public Set<String> allFilterFields()
Returns all filter fields in this profile and any profile it inherits.
-
clone
public RankProfile clone()
Shallow clones this
-
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()
-
typeContext
public MapEvaluationTypeContext typeContext(com.yahoo.search.query.profile.QueryProfileRegistry queryProfiles, Map<com.yahoo.searchlib.rankingexpression.Reference,com.yahoo.tensor.TensorType> featureTypes)
-
-