Class: Ferret::Search::ScoreDocComparator

Inherits:
Object
  • Object
show all
Defined in:
lib/ferret/search/score_doc_comparator.rb

Overview

Expert: Compares two ScoreDoc objects for sorting.

Direct Known Subclasses

SimpleFieldComparator, StringFieldComparator

Constant Summary collapse

RELEVANCE =

Special comparator for sorting hits according to computed relevance (score).

ScoreDocComparator.new()
INDEX_ORDER =

Special comparator for sorting hits according to index order (number).

ScoreDocComparator.new()

Instance Method Summary collapse

Instance Method Details

#compare(i, j) ⇒ Object

Compares two ScoreDoc objects and returns a result indicating their sort order.

i

First ScoreDoc

j

Second ScoreDoc

returns

-1 if i should come before j 1 if i should come after j 0 if they are equal



42
43
44
# File 'lib/ferret/search/score_doc_comparator.rb', line 42

def compare(i, j)
  return NotImplementedError
end

#sort_typeObject

Returns the type of sort. Should return SortField.SCORE, SortField.DOC, SortField.STRING, SortField.INTEGER, SortField.FLOAT or SortField.CUSTOM. It is not valid to return SortField.AUTO. This is used by multisearchers to determine how to collate results from

their searchers. returns

One of the constants in SortField.

See SortField



66
67
68
# File 'lib/ferret/search/score_doc_comparator.rb', line 66

def sort_type()
  return NotImplementedError
end

#sort_value(i) ⇒ Object

Returns the value used to sort the given document. The object returned must implement the java.io.Serializable interface. This is used by multisearchers to determine how to collate results from their searchers.

See FieldDoc

i

Document

returns

Serializable object



54
55
56
# File 'lib/ferret/search/score_doc_comparator.rb', line 54

def sort_value(i)
  return NotImplementedError
end