Class: Ferret::Search::Weight
- Inherits:
-
Object
- Object
- Ferret::Search::Weight
- Defined in:
- lib/ferret/search/weight.rb
Overview
Expert: Calculate query weights and build query scorers.
The purpose of Weight is to make it so that searching does not modify a Query, so that a Query instance can be reused.
Searcher dependent state of the query should reside in the Weight.
IndexReader dependent state should reside in the Scorer.
A Weight
is used in the following way:
-
A
Weight
is constructed by a top-level query, given aSearcher
(See Query#create_weight). -
The #sum_of_squared_weights() method is called on the
Weight
to compute the query normalization factor Similarity#query_norm(float) of the query clauses contained in the query. -
The query normalization factor is passed to #normalize(). At this point the weighting is complete.
-
A
Scorer
is constructed by #scorer()
Direct Known Subclasses
BooleanQuery::BooleanWeight, FilteredQuery::FilteredWeight, MatchAllDocsQuery::MatchAllDocsWeight, MultiPhraseQuery::MultiPhraseWeight, PhraseQuery::PhraseWeight, Spans::SpanWeight, TermQuery::TermWeight
Instance Method Summary collapse
-
#explain(reader, doc) ⇒ Object
An explanation of the score computation for the named document.
-
#normalize(norm) ⇒ Object
Assigns the query normalization factor to this.
-
#query ⇒ Object
The query that this concerns.
-
#scorer(reader) ⇒ Object
Constructs a scorer for this.
-
#sum_of_squared_weights ⇒ Object
The sum of squared weights of contained query clauses.
-
#value ⇒ Object
The weight for this query.
Instance Method Details
#explain(reader, doc) ⇒ Object
An explanation of the score computation for the named document.
49 50 51 |
# File 'lib/ferret/search/weight.rb', line 49 def explain(reader, doc) raise NotImplementedError end |
#normalize(norm) ⇒ Object
Assigns the query normalization factor to this.
39 40 41 |
# File 'lib/ferret/search/weight.rb', line 39 def normalize(norm) raise NotImplementedError end |
#query ⇒ Object
The query that this concerns.
24 25 26 |
# File 'lib/ferret/search/weight.rb', line 24 def query() raise NotImplementedError end |
#scorer(reader) ⇒ Object
Constructs a scorer for this.
44 45 46 |
# File 'lib/ferret/search/weight.rb', line 44 def scorer(reader) raise NotImplementedError end |
#sum_of_squared_weights ⇒ Object
The sum of squared weights of contained query clauses.
34 35 36 |
# File 'lib/ferret/search/weight.rb', line 34 def sum_of_squared_weights() raise NotImplementedError end |
#value ⇒ Object
The weight for this query.
29 30 31 |
# File 'lib/ferret/search/weight.rb', line 29 def value() raise NotImplementedError end |