RelevanceComparator

Sorts by descending relevance. NOTE: if you are sorting only by descending relevance and then secondarily by ascending docID, performance is faster using TopScoreDocCollector directly (which IndexSearcher.search uses when no Sort is specified).

Constructors

Link copied to clipboard
constructor(numHits: Int)

Functions

Link copied to clipboard
open override fun compare(slot1: Int, slot2: Int): Int

Compare hit at slot1 with hit at slot2.

Link copied to clipboard
open override fun compareBottom(doc: Int): Int

Compare the bottom of the queue with this doc. This will only invoked after setBottom has been called. This should return the same result as FieldComparator.compare} as if bottom were slot1 and the new document were slot 2.

Link copied to clipboard
open override fun compareTop(doc: Int): Int

Compare the top value with this doc. This will only invoked after setTopValue has been called. This should return the same result as FieldComparator.compare} as if topValue were slot1 and the new document were slot 2. This is only called for searches that use searchAfter (deep paging).

Link copied to clipboard
open override fun compareValues(first: Float?, second: Float?): Int

Returns a negative integer if first is less than second, 0 if they are equal and a positive integer otherwise. Default impl to assume the type implements Comparable and invoke .compareTo; be sure to override this method if your FieldComparator's type isn't a Comparable or if your values may sometimes be null

Link copied to clipboard

Returns a competitive iterator

Link copied to clipboard
open override fun copy(slot: Int, doc: Int)

This method is called when a new hit is competitive. You should copy any state associated with this document that will be required for future comparisons, into the specified slot.

Link copied to clipboard
open fun disableSkipping()

Informs the comparator that the skipping of documents should be disabled. This function is called by TopFieldCollector in cases when the skipping functionality should not be applied or not necessary. An example could be when search sort is a part of the index sort, and can be already efficiently handled by TopFieldCollector, and doing extra work for skipping in the comparator is redundant.

Link copied to clipboard

Get a per-segment LeafFieldComparator to collect the given [ ]. All docIDs supplied to this [ ] are relative to the current reader (you must add docBase if you need to map it to a top-level docID).

Link copied to clipboard
open override fun setBottom(bottom: Int)

Set the bottom slot, ie the "weakest" (sorted last) entry in the queue. When .compareBottom is called, you should compare against this slot. This will always be called before .compareBottom.

Link copied to clipboard

Informs this leaf comparator that hits threshold is reached. This method is called from a collector when hits threshold is reached.

Link copied to clipboard
open override fun setScorer(scorer: Scorable)

Sets the Scorer to use in case a document's score is needed.

Link copied to clipboard
open fun setSingleSort()

Informs the comparator that sort is done on this single field. This is useful to enable some optimizations for skipping non-competitive documents.

Link copied to clipboard
open override fun setTopValue(value: Float?)

Record the top value, for future calls to LeafFieldComparator.compareTop. This is only called for searches that use searchAfter (deep paging), and is called before any calls to .getLeafComparator.

Link copied to clipboard
open override fun value(slot: Int): Float?

Return the actual value in the slot.