Class RankProfile

java.lang.Object
com.yahoo.schema.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
  • Field Details

  • Constructor Details

    • RankProfile

      public RankProfile(String name, Schema schema, RankProfileRegistry rankProfileRegistry)
      Creates a new rank profile for a particular schema
      Parameters:
      name - the name of the new profile
      schema - the schema owning this profile
      rankProfileRegistry - the RankProfileRegistry to use for storing and looking up rank profiles.
    • RankProfile

      public RankProfile(String name, Schema schema, com.yahoo.config.application.api.ApplicationPackage applicationPackage, com.yahoo.config.application.api.DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry)
      Creates a global rank profile
      Parameters:
      name - the name of the new profile
  • Method Details

    • 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
    • isStrict

      public boolean isStrict()
      Returns whether type checking should fail if this profile accesses query features that are not defined in query profile types. Default is false.
    • declaredStrict

      public Boolean declaredStrict()
      Returns the strict value declared in this or any parent profile.
    • setStrict

      public void setStrict(Boolean strict)
    • 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 return
      type - 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.
    • add

      public void add(RankProfile.Constant constant)
    • declaredConstants

      public Map<com.yahoo.searchlib.rankingexpression.Reference,RankProfile.Constant> declaredConstants()
      Returns an unmodifiable view of the constants declared in this
    • constants

      public Map<com.yahoo.searchlib.rankingexpression.Reference,RankProfile.Constant> constants()
      Returns an unmodifiable view of the constants available in this
    • add

      public void add(OnnxModel model)
    • declaredOnnxModels

      public Map<String,OnnxModel> declaredOnnxModels()
      Returns an unmodifiable map of the onnx models declared in this.
    • onnxModels

      public Map<String,OnnxModel> onnxModels()
      Returns an unmodifiable map of the onnx models available in this.
    • addAttributeType

      public void addAttributeType(String attributeName, String attributeType)
    • getAttributeTypes

      public Map<String,String> getAttributeTypes()
    • 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.
    • addRankProperty

      public void addRankProperty(String name, String parameter)
    • 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)
    • setPostFilterThreshold

      public void setPostFilterThreshold(double threshold)
    • setApproximateThreshold

      public void setApproximateThreshold(double threshold)
    • getTermwiseLimit

      public OptionalDouble getTermwiseLimit()
    • getPostFilterThreshold

      public OptionalDouble getPostFilterThreshold()
    • getApproximateThreshold

      public OptionalDouble getApproximateThreshold()
    • 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
    • addInput

      public void addInput(com.yahoo.searchlib.rankingexpression.Reference reference, RankProfile.Input input)
      Adds the type of an input feature consumed by this profile. All inputs must either be declared through this or in query profile types, otherwise they are assumes to be scalars.
    • inputs

      public Map<com.yahoo.searchlib.rankingexpression.Reference,RankProfile.Input> inputs()
      Returns the inputs of this, which also includes all inputs of the parents of this.
    • addMutateOperation

      public void addMutateOperation(RankProfile.MutateOperation op)
    • 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

      Returns an unmodifiable snapshot of the functions in this
    • filterFields

      public Set<String> filterFields()
    • allFilterFields

      public Set<String> allFilterFields()
      Returns all filter fields in this profile and any profile it inherits.
    • clone

      public RankProfile clone()
      Shallow clones this
      Overrides:
      clone in class 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()
    • typeContext

      public MapEvaluationTypeContext typeContext(com.yahoo.search.query.profile.QueryProfileRegistry queryProfiles, Map<com.yahoo.searchlib.rankingexpression.Reference,com.yahoo.tensor.TensorType> featureTypes)
    • toString

      public String toString()
      Overrides:
      toString in class Object