org.apache.lucene.search

## Class RandomAccessWeight

- java.lang.Object
- - org.apache.lucene.search.Weight
  - - org.apache.lucene.search.ConstantScoreWeight
    - - org.apache.lucene.search.RandomAccessWeight

-     public abstract class RandomAccessWeight
      extends ConstantScoreWeight

  Base class to build `Weight`s that are based on random-access structures such as live docs or doc values. Such weights return a `Scorer` which consists of an approximation that matches everything, and a confirmation phase that first checks live docs and then the `Bits` returned by `getMatchingDocs(LeafReaderContext)`.
  NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.lucene.search.Weight

      `Weight.DefaultBulkScorer`

  - ### Field Summary

    - ### Fields inherited from class org.apache.lucene.search.Weight

      `parentQuery`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `RandomAccessWeight(Query query)` Sole constructor.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract Bits` | `getMatchingDocs(LeafReaderContext context)` Return a `Bits` instance representing documents that match this weight on the given context.
    `Scorer` | `scorer(LeafReaderContext context)` Returns a `Scorer` which can iterate in order over all matching documents and assign them a score.

    - ### Methods inherited from class org.apache.lucene.search.ConstantScoreWeight

      `boost, explain, extractTerms, getValueForNormalization, normalize, queryNorm, score`

    - ### Methods inherited from class org.apache.lucene.search.Weight

      `bulkScorer, getQuery, scorerSupplier`

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

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

- - ### Constructor Detail

    - #### RandomAccessWeight

          protected RandomAccessWeight(Query query)

      Sole constructor.

  - ### Method Detail

    - #### getMatchingDocs

          protected abstract Bits getMatchingDocs(LeafReaderContext context)
                                           throws IOException

      Return a `Bits` instance representing documents that match this weight on the given context. A return value of `null` indicates that no documents matched. Note: it is not needed to care about live docs as they will be checked before the returned bits.
      Throws:
        `IOException`

    - #### scorer

          public final Scorer scorer(LeafReaderContext context)
                              throws IOException

      Description copied from class: `Weight`
      Returns a `Scorer` which can iterate in order over all matching documents and assign them a score.

      NOTE: null can be returned if no documents will be scored by this query.

      NOTE: The returned `Scorer` does not have `LeafReader.getLiveDocs()` applied, they need to be checked on top.

      Specified by:
        `scorer` in class `Weight`
      Parameters:
        `context` - the `LeafReaderContext` for which to return the `Scorer`.
      Returns:
        a `Scorer` which scores documents in/out-of order.
      Throws:
        `IOException` - if there is a low-level I/O error

Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.