Weight

abstract class Weight : SegmentCacheable

Expert: Calculate query weights and build query scorers.

The purpose of Weight is to ensure searching does not modify a Query, so that a Query instance can be reused.

IndexSearcher dependent state of the query should reside in the Weight.

org.gnit.lucenekmp.index.LeafReader dependent state should reside in the [ ].

Since Weight creates Scorer instances for a given [ ] (.scorer) callers must maintain the relationship between the searcher's top-level IndexReaderContext and the context used to create a Scorer.

A Weight is used in the following way:

  1. A Weight is constructed by a top-level query, given a IndexSearcher * (Query.createWeight).

  2. A Scorer is constructed by .scorer.

Since

2.9

Inheritors

Types

Link copied to clipboard

Just wraps a Scorer and performs top scoring using it.

Properties

Link copied to clipboard
open val query: Query

The query that this concerns.

Functions

Link copied to clipboard

Helper method that delegates to .scorerSupplier. It is implemented as

Link copied to clipboard
open fun count(context: LeafReaderContext): Int

Counts the number of live documents that match a given this.query in a leaf.

Link copied to clipboard
abstract fun explain(context: LeafReaderContext, doc: Int): Explanation

An explanation of the score computation for the named document.

Link copied to clipboard
Link copied to clipboard
open fun matches(context: LeafReaderContext, doc: Int): Matches?

Returns Matches for a specific document, or null if the document does not match the parent query

Link copied to clipboard

Optional method that delegates to scorerSupplier.

Link copied to clipboard

Get a ScorerSupplier, which allows knowing the cost of the Scorer before building it. A scorer supplier for the same LeafReaderContext instance may be requested multiple times as part of a single search call.