Class: Ferret::Search::Weight

Inherits:
Object
  • Object
show all
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:

  1. A Weight is constructed by a top-level query, given a Searcher (See Query#create_weight).

  2. 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.

  3. The query normalization factor is passed to #normalize(). At this point the weighting is complete.

  4. A Scorer is constructed by #scorer()

Instance Method Summary collapse

Instance Method Details

#explain(reader, doc) ⇒ Object

An explanation of the score computation for the named document.

Raises:

  • (NotImplementedError)


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.

Raises:

  • (NotImplementedError)


39
40
41
# File 'lib/ferret/search/weight.rb', line 39

def normalize(norm)
  raise NotImplementedError
end

#queryObject

The query that this concerns.

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/ferret/search/weight.rb', line 24

def query()
  raise NotImplementedError
end

#scorer(reader) ⇒ Object

Constructs a scorer for this.

Raises:

  • (NotImplementedError)


44
45
46
# File 'lib/ferret/search/weight.rb', line 44

def scorer(reader)
  raise NotImplementedError
end

#sum_of_squared_weightsObject

The sum of squared weights of contained query clauses.

Raises:

  • (NotImplementedError)


34
35
36
# File 'lib/ferret/search/weight.rb', line 34

def sum_of_squared_weights()
  raise NotImplementedError
end

#valueObject

The weight for this query.

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/ferret/search/weight.rb', line 29

def  value()
  raise NotImplementedError
end