Interface TermWeightor

  • All Superinterfaces:
    java.util.function.ToDoubleFunction<Term>

    public interface TermWeightor
    extends java.util.function.ToDoubleFunction<Term>
    Calculates the weight of a Term
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static TermWeightor DEFAULT
      A default TermWeightor based on token length
    • Method Summary

      Static Methods 
      Modifier and Type Method Description
      static TermWeightor combine​(TermWeightor... weightors)
      Combine weightors by multiplication
      static TermWeightor fieldWeightor​(double weight, java.lang.String... fields)
      QueryTerms with a field from the selected set will be assigned the given weight
      static TermWeightor fieldWeightor​(double weight, java.util.Set<java.lang.String> fields)
      QueryTerms with a field from the selected set will be assigned the given weight
      static TermWeightor lengthWeightor​(double a, double k)
      QueryTerms will be assigned a weight based on their term length Weights are assigned by the function a * e ^ (-k * length).
      static TermWeightor termAndFieldWeightor​(double weight, java.util.Set<Term> terms)
      QueryTerms with a term and field value from the selected set will be assigned the given weight
      static TermWeightor termAndFieldWeightor​(double weight, Term... terms)
      QueryTerms with a term and field value from the selected set will be assigned the given weight
      static TermWeightor termFreqWeightor​(java.util.Map<java.lang.String,​java.lang.Integer> frequencies, double n, double k)
      QueryTerms will be assigned a weight based on their term frequency More infrequent terms are weighted higher.
      static TermWeightor termWeightor​(double weight, java.util.Set<BytesRef> terms)
      QueryTerms with a term value from the selected set will be assigned the given weight
      static TermWeightor termWeightor​(double weight, BytesRef... terms)
      QueryTerms with a term value from the selected set will be assigned the given weight
      • Methods inherited from interface java.util.function.ToDoubleFunction

        applyAsDouble
    • Field Detail

      • DEFAULT

        static final TermWeightor DEFAULT
        A default TermWeightor based on token length
    • Method Detail

      • fieldWeightor

        static TermWeightor fieldWeightor​(double weight,
                                          java.util.Set<java.lang.String> fields)
        QueryTerms with a field from the selected set will be assigned the given weight
      • fieldWeightor

        static TermWeightor fieldWeightor​(double weight,
                                          java.lang.String... fields)
        QueryTerms with a field from the selected set will be assigned the given weight
      • termWeightor

        static TermWeightor termWeightor​(double weight,
                                         java.util.Set<BytesRef> terms)
        QueryTerms with a term value from the selected set will be assigned the given weight
      • termWeightor

        static TermWeightor termWeightor​(double weight,
                                         BytesRef... terms)
        QueryTerms with a term value from the selected set will be assigned the given weight
      • termAndFieldWeightor

        static TermWeightor termAndFieldWeightor​(double weight,
                                                 java.util.Set<Term> terms)
        QueryTerms with a term and field value from the selected set will be assigned the given weight
      • termAndFieldWeightor

        static TermWeightor termAndFieldWeightor​(double weight,
                                                 Term... terms)
        QueryTerms with a term and field value from the selected set will be assigned the given weight
      • termFreqWeightor

        static TermWeightor termFreqWeightor​(java.util.Map<java.lang.String,​java.lang.Integer> frequencies,
                                             double n,
                                             double k)
        QueryTerms will be assigned a weight based on their term frequency More infrequent terms are weighted higher. Terms are weighted according to the function w = (n / freq) + k. Terms with no associated frequency receive a weight of value 1
        Parameters:
        frequencies - a map of terms to frequencies
        n - a scaling factor
        k - the minimum weight to scale to
      • lengthWeightor

        static TermWeightor lengthWeightor​(double a,
                                           double k)
        QueryTerms will be assigned a weight based on their term length Weights are assigned by the function a * e ^ (-k * length). Longer terms are weighted higher. Terms of length greater than 32 all receive the same weight.
        Parameters:
        a - a
        k - k