Class FieldComparer.RelevanceComparer
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 all overloads of Search(Query, int) use when no Sort is specified).
Inherited Members
Namespace: Lucene.Net.Search
Assembly: Lucene.Net.dll
Syntax
public sealed class FieldComparer.RelevanceComparer : FieldComparer<Single>
Properties
this[int]
Return the actual value in the slot. LUCENENET NOTE: This was value(int) in Lucene.
Declaration
public override Single this[int slot] { get; }
Parameters
Type | Name | Description |
---|---|---|
int | slot | The value |
Property Value
Type | Description |
---|---|
Single | Value in this slot |
Overrides
Methods
Compare(int, int)
Compare hit at slot1
with hit at slot2
.
Declaration
public override int Compare(int slot1, int slot2)
Parameters
Type | Name | Description |
---|---|---|
int | slot1 | first slot to compare |
int | slot2 | second slot to compare |
Returns
Type | Description |
---|---|
int | any N < 0 if |
Overrides
CompareBottom(int)
Compare the bottom of the queue with this doc. This will only invoked after SetBottom(int) has been called. This should return the same result as Compare(int, int) as if bottom were slot1 and the new document were slot 2.
For a search that hits many results, this method will be the hotspot (invoked by far the most frequently).
Declaration
public override int CompareBottom(int doc)
Parameters
Type | Name | Description |
---|---|---|
int | doc | Doc that was hit |
Returns
Type | Description |
---|---|
int | Any N < 0 if the doc's value is sorted after the bottom entry (not competitive), any N > 0 if the doc's value is sorted before the bottom entry and 0 if they are equal. |
Overrides
CompareTop(int)
Compare the top value with this doc. This will only invoked after SetTopValue(T) has been called. This should return the same result as Compare(int, int) as if topValue were slot1 and the new document were slot 2. This is only called for searches that use SearchAfter (deep paging).
Declaration
public override int CompareTop(int doc)
Parameters
Type | Name | Description |
---|---|---|
int | doc | Doc that was hit |
Returns
Type | Description |
---|---|
int | Any N < 0 if the doc's value is sorted after the bottom entry (not competitive), any N > 0 if the doc's value is sorted before the bottom entry and 0 if they are equal. |
Overrides
CompareValues(Single, Single)
Returns -1 if first is less than second. Default
implementation to assume the type implements IComparable<T> and
invoke CompareTo(T); be sure to override this method if
your FieldComparer<T>'s type isn't a IComparable<T> or
if you need special null
handling.
Declaration
public override int CompareValues(Single first, Single second)
Parameters
Type | Name | Description |
---|---|---|
Single | first | |
Single | second |
Returns
Type | Description |
---|---|
int |
Overrides
Copy(int, 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.
Declaration
public override void Copy(int slot, int doc)
Parameters
Type | Name | Description |
---|---|---|
int | slot | Which slot to copy the hit to |
int | doc | DocID relative to current reader |
Overrides
SetBottom(int)
Set the bottom slot, ie the "weakest" (sorted last) entry in the queue. When CompareBottom(int) is called, you should compare against this slot. This will always be called before CompareBottom(int).
Declaration
public override void SetBottom(int slot)
Parameters
Type | Name | Description |
---|---|---|
int | slot | the currently weakest (sorted last) slot in the queue |
Overrides
SetNextReader(AtomicReaderContext)
Set a new AtomicReaderContext. All subsequent docIDs are relative to the current reader (you must add docBase if you need to map it to a top-level docID).
Declaration
public override FieldComparer SetNextReader(AtomicReaderContext context)
Parameters
Type | Name | Description |
---|---|---|
AtomicReaderContext | context | Current reader context |
Returns
Type | Description |
---|---|
FieldComparer | The comparer to use for this segment; most comparers can just return "this" to reuse the same comparer across segments |
Overrides
Exceptions
Type | Condition |
---|---|
IOException | If there is a low-level IO error |
SetScorer(Scorer)
Sets the Scorer to use in case a document's score is needed.
Declaration
public override void SetScorer(Scorer scorer)
Parameters
Type | Name | Description |
---|---|---|
Scorer | scorer | Scorer instance that you should use to obtain the current hit's score, if necessary. |
Overrides
SetTopValue(Single)
Record the top value, for future calls to CompareTop(int). This is only called for searches that use SearchAfter (deep paging), and is called before any calls to SetNextReader(AtomicReaderContext).
Declaration
public override void SetTopValue(Single value)
Parameters
Type | Name | Description |
---|---|---|
Single | value |