Class ConstantScoreWeight

  • All Implemented Interfaces:

    public abstract class ConstantScoreWeight
    extends Weight
    A Weight that has a constant score equal to the boost of the wrapped query. This is typically useful when building queries which do not produce meaningful scores and are mostly useful for filtering.
    NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
    • Constructor Detail

      • ConstantScoreWeight

        protected ConstantScoreWeight​(Query query,
                                      float score)
    • Method Detail

      • extractTerms

        public void extractTerms​(Set<Term> terms)
        Description copied from class: Weight
        Expert: adds all terms occurring in this query to the terms set. If the Weight was created with needsScores == true then this method will only extract terms which are used for scoring, otherwise it will extract all terms which are used for matching.
        Specified by:
        extractTerms in class Weight
      • score

        protected final float score()
        Return the score produced by this Weight.
      • explain

        public Explanation explain​(LeafReaderContext context,
                                   int doc)
                            throws IOException
        Description copied from class: Weight
        An explanation of the score computation for the named document.
        Specified by:
        explain in class Weight
        context - the readers context to create the Explanation for.
        doc - the document's id relative to the given context's reader
        an Explanation for the score
        IOException - if an IOException occurs