Class DocBoostMatcher

java.lang.Object
org.codelibs.fess.indexer.DocBoostMatcher

public class DocBoostMatcher extends Object
A matcher class for applying document boost values based on configurable expressions. This class evaluates match and boost expressions against document data to determine if a document should receive a boost and what boost value to apply. It supports script-based expressions for flexible document scoring.
  • Constructor Details

    • DocBoostMatcher

      public DocBoostMatcher()
      Default constructor that creates a DocBoostMatcher with default script type. Uses the default script engine as defined in Constants.DEFAULT_SCRIPT.
    • DocBoostMatcher

      public DocBoostMatcher(org.codelibs.fess.opensearch.config.exentity.BoostDocumentRule rule)
      Constructor that creates a DocBoostMatcher from a BoostDocumentRule.
      Parameters:
      rule - the boost document rule containing match and boost expressions
  • Method Details

    • match

      public boolean match(Map<String,Object> map)
      Determines if the given document data matches the configured match expression.
      Parameters:
      map - the document data as a map of field names to values
      Returns:
      true if the document matches the expression, false otherwise
    • getValue

      public float getValue(Map<String,Object> map)
      Calculates the boost value for the given document data using the boost expression. The method evaluates the boost expression and converts the result to a float value. Supports Integer, Long, Float, Double, and String representations of numbers.
      Parameters:
      map - the document data as a map of field names to values
      Returns:
      the calculated boost value as a float, or 0.0f if evaluation fails
    • getBoostExpression

      public String getBoostExpression()
      Gets the current boost expression.
      Returns:
      the boost expression string
    • setBoostExpression

      public void setBoostExpression(String expression)
      Sets the boost expression used to calculate boost values.
      Parameters:
      expression - the boost expression string
    • getMatchExpression

      public String getMatchExpression()
      Gets the current match expression.
      Returns:
      the match expression string
    • setMatchExpression

      public void setMatchExpression(String expression)
      Sets the match expression used to determine if documents should be boosted.
      Parameters:
      expression - the match expression string