ConstantScoreScorerSupplier (Lucene 10.5.0 core API)
Description: declaration: package: org.apache.lucene.search, class: ConstantScoreScorerSupplier

Package org.apache.lucene.search

# Class ConstantScoreScorerSupplier

java.lang.Object
org.apache.lucene.search.ScorerSupplier
org.apache.lucene.search.ConstantScoreScorerSupplier

public abstract class ConstantScoreScorerSupplier extends ScorerSupplier
Specialization of `ScorerSupplier` for queries that produce constant scores.

NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `ConstantScoreScorerSupplier(float score, ScoreMode scoreMode, int maxDoc)`
  Constructor, invoked by sub-classes.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `final BulkScorer`
  `bulkScorer()`
  Optional method: Get a scorer that is optimized for bulk-scoring.
  `static ConstantScoreScorerSupplier`
  `fromIterator(DocIdSetIterator iterator, float score, ScoreMode scoreMode, int maxDoc)`
  Create a `ConstantScoreScorerSupplier` for the given iterator.
  `final Scorer`
  `get(long leadCost)`
  Get the `Scorer`.
  `abstract DocIdSetIterator`
  `iterator(long leadCost)`
  Return an iterator given the cost of the leading clause.
  `static ConstantScoreScorerSupplier`
  `matchAll(float score, ScoreMode scoreMode, int maxDoc)`
  Create a `ConstantScoreScorerSupplier` that matches all docs in [0, maxDoc).

  ### Methods inherited from class org.apache.lucene.search.ScorerSupplier

  `cost, setTopLevelScoringClause`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ConstantScoreScorerSupplier

    protected ConstantScoreScorerSupplier(float score, ScoreMode scoreMode, int maxDoc)
    Constructor, invoked by sub-classes.

- ## Method Details

  - ### matchAll

    public static ConstantScoreScorerSupplier matchAll(float score, ScoreMode scoreMode, int maxDoc)
    Create a `ConstantScoreScorerSupplier` that matches all docs in [0, maxDoc).

  - ### fromIterator

    public static ConstantScoreScorerSupplier fromIterator(DocIdSetIterator iterator, float score, ScoreMode scoreMode, int maxDoc)
    Create a `ConstantScoreScorerSupplier` for the given iterator.

  - ### iterator

    public abstract DocIdSetIterator iterator(long leadCost) throws IOException
    Return an iterator given the cost of the leading clause.
    Throws:
      `IOException`

  - ### get

    public final Scorer get(long leadCost) throws IOException
    Description copied from class: `ScorerSupplier`
    Get the `Scorer`. This may not return `null` and must be called at most once.
    Specified by:
      `get` in class `ScorerSupplier`
    Parameters:
      `leadCost` - Cost of the scorer that will be used in order to lead iteration. This can be interpreted as an upper bound of the number of times that `DocIdSetIterator.nextDoc()`, `DocIdSetIterator.advance(int)` and `TwoPhaseIterator.matches()` will be called. Under doubt, pass `Long.MAX_VALUE`, which will produce a `Scorer` that has good iteration capabilities.
    Throws:
      `IOException`

  - ### bulkScorer

    public final BulkScorer bulkScorer() throws IOException
    Description copied from class: `ScorerSupplier`
    Optional method: Get a scorer that is optimized for bulk-scoring. The default implementation iterates matches from the `Scorer` but some queries can have more efficient approaches for matching all hits.
    Overrides:
      `bulkScorer` in class `ScorerSupplier`
    Throws:
      `IOException`