Lucene.Net  3.0.3
Lucene.Net is a .NET port of the Java Lucene Indexing Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties
Classes | Public Member Functions | Properties | List of all members
Lucene.Net.Search.FieldComparator Class Referenceabstract

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.
 

Detailed Description

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:

NOTE: This API is experimental and might change in incompatible ways in the next release.

Definition at line 83 of file FieldComparator.cs.

Member Function Documentation

abstract int Lucene.Net.Search.FieldComparator.Compare ( int  slot1,
int  slot2 
)
pure virtual
abstract int Lucene.Net.Search.FieldComparator.CompareBottom ( int  doc)
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).

Parameters
docthat was hit
Returns
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.

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.

abstract void Lucene.Net.Search.FieldComparator.Copy ( int  slot,
int  doc 
)
pure virtual
abstract void Lucene.Net.Search.FieldComparator.SetBottom ( int  slot)
pure virtual
abstract void Lucene.Net.Search.FieldComparator.SetNextReader ( IndexReader  reader,
int  docBase 
)
pure virtual
virtual void Lucene.Net.Search.FieldComparator.SetScorer ( Scorer  scorer)
virtual

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

Parameters
scorerScorer 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.

Property Documentation

abstract IComparable Lucene.Net.Search.FieldComparator.this[int slot]
get

Return the actual value in the slot.

Parameters
slotthe value
Returns
value in this slot upgraded to Comparable

Definition at line 171 of file FieldComparator.cs.


The documentation for this class was generated from the following file: