Enum RewriteMethod

java.lang.Object
java.lang.Enum<RewriteMethod>
org.hibernate.search.engine.search.common.RewriteMethod
All Implemented Interfaces:
Serializable, Comparable<RewriteMethod>

public enum RewriteMethod extends Enum<RewriteMethod>
The rewrite parameter determines:
  • How Lucene calculates the relevance scores for each matching document
  • Whether Lucene changes the original query to a bool query or bit set
  • If changed to a bool query, which term query clauses are included

For more details on rewrite methods, and in particular which options are allowed, see the backend specific documentation, e.g. Elasticsearch rewrite parameters page, OpenSearch query string parameters table or Lucene MultiTermQuery.

  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    A rewrite method that first creates a private Filter, by visiting each term in sequence and marking all docs for that term.
    Like SCORING_BOOLEAN except scores are not computed.
    A rewrite method that first translates each term into a should clause of a boolean query, and keeps the scores as computed by the query.
    A rewrite method that first translates each term into a should clause of a boolean query, but adjusts the frequencies used for scoring to be blended across the terms, otherwise the rarest term typically ranks highest (often not useful e.g.
    A rewrite method that first translates each term into a should clause in a boolean query, but the scores are only computed as the boost.
    A rewrite method that first translates each term into a should clause in a boolean query, and keeps the scores as computed by the query.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the enum constant of this type with the specified name.
    static RewriteMethod[]
    Returns an array containing the constants of this enum type, in the order they are declared.

    Methods inherited from class java.lang.Enum

    clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • CONSTANT_SCORE

      public static final RewriteMethod CONSTANT_SCORE
      A rewrite method that first creates a private Filter, by visiting each term in sequence and marking all docs for that term. Matching documents are assigned a constant score equal to the query's boost.

      This method is faster than the BooleanQuery rewrite methods when the number of matched terms or matched documents is non-trivial. Also, it will never hit a TooManyClauses exception.

      Can only be used with QueryStringPredicateOptionsStep.rewriteMethod(RewriteMethod).

    • CONSTANT_SCORE_BOOLEAN

      public static final RewriteMethod CONSTANT_SCORE_BOOLEAN
      Like SCORING_BOOLEAN except scores are not computed. Instead, each matching document receives a constant score equal to the query's boost.

      This rewrite method can hit TooManyClauses exception.

      Can only be used with QueryStringPredicateOptionsStep.rewriteMethod(RewriteMethod).

    • SCORING_BOOLEAN

      public static final RewriteMethod SCORING_BOOLEAN
      A rewrite method that first translates each term into a should clause of a boolean query, and keeps the scores as computed by the query. Note that typically such scores are meaningless to the user, and require non-trivial CPU to compute, so it's almost always better to use CONSTANT_SCORE instead.

      This rewrite method can hit TooManyClauses exception.

      Can only be used with QueryStringPredicateOptionsStep.rewriteMethod(RewriteMethod).

    • TOP_TERMS_BLENDED_FREQS_N

      public static final RewriteMethod TOP_TERMS_BLENDED_FREQS_N
      A rewrite method that first translates each term into a should clause of a boolean query, but adjusts the frequencies used for scoring to be blended across the terms, otherwise the rarest term typically ranks highest (often not useful e.g. in the set of expanded terms in a fuzzy query).

      This rewrite method only uses the top scoring terms, so it will not overflow the boolean max clause count.

      Can only be used with QueryStringPredicateOptionsStep.rewriteMethod(RewriteMethod, int).

    • TOP_TERMS_BOOST_N

      public static final RewriteMethod TOP_TERMS_BOOST_N
      A rewrite method that first translates each term into a should clause in a boolean query, but the scores are only computed as the boost.

      This rewrite method only uses the top scoring terms, so it will not overflow the boolean max clause count.

      Can only be used with QueryStringPredicateOptionsStep.rewriteMethod(RewriteMethod, int).

    • TOP_TERMS_N

      public static final RewriteMethod TOP_TERMS_N
      A rewrite method that first translates each term into a should clause in a boolean query, and keeps the scores as computed by the query.

      This rewrite method only uses the top scoring terms, so it will not overflow the boolean max clause count.

      Can only be used with QueryStringPredicateOptionsStep.rewriteMethod(RewriteMethod, int).

  • Method Details

    • values

      public static RewriteMethod[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static RewriteMethod valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null