Lucene.Net
3.0.3
Lucene.Net is a .NET port of the Java Lucene Indexing Library
|
Expert: a FieldComparator compares hits so as to determine their sort order when collecting the top results with TopFieldCollector . The concrete public FieldComparator classes here correspond to the SortField types. More...
Inherited by Lucene.Net.Search.FieldComparator.ByteComparator, Lucene.Net.Search.FieldComparator.DocComparator, Lucene.Net.Search.FieldComparator.DoubleComparator, Lucene.Net.Search.FieldComparator.FloatComparator, Lucene.Net.Search.FieldComparator.IntComparator, Lucene.Net.Search.FieldComparator.LongComparator, Lucene.Net.Search.FieldComparator.RelevanceComparator, Lucene.Net.Search.FieldComparator.ShortComparator, Lucene.Net.Search.FieldComparator.StringComparatorLocale, Lucene.Net.Search.FieldComparator.StringOrdValComparator, and Lucene.Net.Search.FieldComparator.StringValComparator.
Classes | |
class | ByteComparator |
Parses field's values as byte (using FieldCache.GetBytes(Lucene.Net.Index.IndexReader,string) and sorts by ascending value More... | |
class | DocComparator |
Sorts by ascending docID More... | |
class | DoubleComparator |
Parses field's values as double (using FieldCache.GetDoubles(Lucene.Net.Index.IndexReader,string) and sorts by ascending value More... | |
class | FloatComparator |
Parses field's values as float (using FieldCache.GetFloats(Lucene.Net.Index.IndexReader,string) and sorts by ascending value More... | |
class | IntComparator |
Parses field's values as int (using FieldCache.GetInts(Lucene.Net.Index.IndexReader,string) and sorts by ascending value More... | |
class | LongComparator |
Parses field's values as long (using FieldCache.GetLongs(Lucene.Net.Index.IndexReader,string) and sorts by ascending value More... | |
class | RelevanceComparator |
Sorts by descending relevance. NOTE: if you are sorting only by descending relevance and then secondarily by ascending docID, peformance is faster using TopScoreDocCollector directly (which Searcher.Search(Query, int) uses when no Sort is specified). More... | |
class | ShortComparator |
Parses field's values as short (using FieldCache.GetShorts(IndexReader, string)) and sorts by ascending value More... | |
class | StringComparatorLocale |
Sorts by a field's value using the Collator for a given Locale. More... | |
class | StringOrdValComparator |
Sorts by field's natural String sort order, using ordinals. This is functionally equivalent to FieldComparator.StringValComparator , but it first resolves the string to their relative ordinal positions (using the index returned by FieldCache.GetStringIndex), and does most comparisons using the ordinals. For medium to large results, this comparator will be much faster than FieldComparator.StringValComparator. For very small result sets it may be slower. More... | |
class | StringValComparator |
Sorts by field's natural String sort order. All comparisons are done using String.compareTo, which is slow for medium to large result sets but possibly very fast for very small results sets. More... | |
Public Member Functions | |
abstract int | Compare (int slot1, int slot2) |
Compare hit at slot1 with hit at slot2. | |
abstract void | SetBottom (int slot) |
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. | |
abstract int | CompareBottom (int doc) |
Compare the bottom of the queue with doc. This will only invoked after setBottom 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. | |
abstract void | Copy (int slot, int doc) |
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. | |
abstract void | SetNextReader (IndexReader reader, int docBase) |
Set a new Reader. All doc correspond to the current Reader. | |
virtual void | SetScorer (Scorer scorer) |
Sets the Scorer to use in case a document's score is needed. | |
Properties | |
abstract IComparable | this[int slot] [get] |
Return the actual value in the slot. | |
Expert: a FieldComparator compares hits so as to determine their sort order when collecting the top results with TopFieldCollector . The concrete public FieldComparator classes here correspond to the SortField types.
This API is designed to achieve high performance sorting, by exposing a tight interaction with FieldValueHitQueue as it visits hits. Whenever a hit is competitive, it's enrolled into a virtual slot, which is an int ranging from 0 to numHits-1. The FieldComparator is made aware of segment transitions during searching in case any internal state it's tracking needs to be recomputed during these transitions.
A comparator must define these functions:
Compare Compare a hit at 'slot a' with hit 'slot b'.
SetBottom This method is called by FieldValueHitQueue to notify the FieldComparator of the current weakest ("bottom") slot. Note that this slot may not hold the weakest value according to your comparator, in cases where your comparator is not the primary one (ie, is only used to break ties from the comparators before it).
CompareBottom Compare a new hit (docID) against the "weakest" (bottom) entry in the queue.
Copy Installs a new hit into the priority queue. The FieldValueHitQueue calls this method when a new hit is competitive.
SetNextReader Invoked when the search is switching to the next segment. You may need to update internal state of the comparator, for example retrieving new values from the FieldCache.
NOTE: This API is experimental and might change in incompatible ways in the next release.
Definition at line 83 of file FieldComparator.cs.
|
pure virtual |
Compare hit at slot1 with hit at slot2.
slot1 | first slot to compare |
slot2 | second slot to compare |
Implemented in Lucene.Net.Search.FieldComparator.StringValComparator, Lucene.Net.Search.FieldComparator.StringOrdValComparator, Lucene.Net.Search.FieldComparator.StringComparatorLocale, Lucene.Net.Search.FieldComparator.ShortComparator, Lucene.Net.Search.FieldComparator.RelevanceComparator, Lucene.Net.Search.FieldComparator.LongComparator, Lucene.Net.Search.FieldComparator.IntComparator, Lucene.Net.Search.FieldComparator.FloatComparator, Lucene.Net.Search.FieldComparator.DoubleComparator, Lucene.Net.Search.FieldComparator.DocComparator, and Lucene.Net.Search.FieldComparator.ByteComparator.
|
pure virtual |
Compare the bottom of the queue with doc. This will only invoked after setBottom 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).
doc | that was hit |
Implemented in Lucene.Net.Search.FieldComparator.StringValComparator, Lucene.Net.Search.FieldComparator.StringOrdValComparator, Lucene.Net.Search.FieldComparator.StringComparatorLocale, Lucene.Net.Search.FieldComparator.ShortComparator, Lucene.Net.Search.FieldComparator.RelevanceComparator, Lucene.Net.Search.FieldComparator.LongComparator, Lucene.Net.Search.FieldComparator.IntComparator, Lucene.Net.Search.FieldComparator.FloatComparator, Lucene.Net.Search.FieldComparator.DoubleComparator, Lucene.Net.Search.FieldComparator.DocComparator, and Lucene.Net.Search.FieldComparator.ByteComparator.
|
pure virtual |
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.
slot | which slot to copy the hit to |
doc | docID relative to current reader |
Implemented in Lucene.Net.Search.FieldComparator.StringValComparator, Lucene.Net.Search.FieldComparator.StringOrdValComparator, Lucene.Net.Search.FieldComparator.StringComparatorLocale, Lucene.Net.Search.FieldComparator.ShortComparator, Lucene.Net.Search.FieldComparator.RelevanceComparator, Lucene.Net.Search.FieldComparator.LongComparator, Lucene.Net.Search.FieldComparator.IntComparator, Lucene.Net.Search.FieldComparator.FloatComparator, Lucene.Net.Search.FieldComparator.DoubleComparator, Lucene.Net.Search.FieldComparator.DocComparator, and Lucene.Net.Search.FieldComparator.ByteComparator.
|
pure virtual |
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.
slot | the currently weakest (sorted last) slot in the queue |
Implemented in Lucene.Net.Search.FieldComparator.StringValComparator, Lucene.Net.Search.FieldComparator.StringOrdValComparator, Lucene.Net.Search.FieldComparator.StringComparatorLocale, Lucene.Net.Search.FieldComparator.ShortComparator, Lucene.Net.Search.FieldComparator.RelevanceComparator, Lucene.Net.Search.FieldComparator.LongComparator, Lucene.Net.Search.FieldComparator.IntComparator, Lucene.Net.Search.FieldComparator.FloatComparator, Lucene.Net.Search.FieldComparator.DoubleComparator, Lucene.Net.Search.FieldComparator.DocComparator, and Lucene.Net.Search.FieldComparator.ByteComparator.
|
pure virtual |
Set a new Reader. All doc correspond to the current Reader.
reader | current reader |
docBase | docBase of this reader |
<throws> IOException </throws> <throws> IOException </throws>
Implemented in Lucene.Net.Search.FieldComparator.StringValComparator, Lucene.Net.Search.FieldComparator.StringOrdValComparator, Lucene.Net.Search.FieldComparator.StringComparatorLocale, Lucene.Net.Search.FieldComparator.ShortComparator, Lucene.Net.Search.FieldComparator.RelevanceComparator, Lucene.Net.Search.FieldComparator.LongComparator, Lucene.Net.Search.FieldComparator.IntComparator, Lucene.Net.Search.FieldComparator.FloatComparator, Lucene.Net.Search.FieldComparator.DoubleComparator, Lucene.Net.Search.FieldComparator.DocComparator, and Lucene.Net.Search.FieldComparator.ByteComparator.
|
virtual |
Sets the Scorer to use in case a document's score is needed.
scorer | Scorer instance that you should use to obtain the current hit's score, if necessary. |
Reimplemented in Lucene.Net.Search.FieldComparator.RelevanceComparator.
Definition at line 158 of file FieldComparator.cs.
|
get |
Return the actual value in the slot.
slot | the value |
Definition at line 171 of file FieldComparator.cs.