Class: Ferret::Search::MatchAllDocsQuery::MatchAllScorer

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

Constant Summary

Constants inherited from Scorer

Scorer::MAX_DOCS

Instance Attribute Summary

Attributes inherited from Scorer

#similarity

Instance Method Summary collapse

Methods inherited from Scorer

#each_hit, #each_hit_up_to

Constructor Details

#initialize(reader, similarity) ⇒ MatchAllScorer

Returns a new instance of MatchAllScorer.



11
12
13
14
15
16
# File 'lib/ferret/search/match_all_docs_query.rb', line 11

def initialize(reader, similarity) 
  super(similarity)
  @reader = reader
  @count = -1
  @max_doc = reader.max_doc
end

Instance Method Details

#docObject



18
19
20
# File 'lib/ferret/search/match_all_docs_query.rb', line 18

def doc() 
  return @count
end

#explain(doc) ⇒ Object



22
23
24
# File 'lib/ferret/search/match_all_docs_query.rb', line 22

def explain(doc) 
  return Explanation.new(1.0, "MatchAllDocsQuery")
end

#next?Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
32
33
34
# File 'lib/ferret/search/match_all_docs_query.rb', line 26

def next? 
  while (@count < (@max_doc - 1)) 
    @count += 1
    if (!@reader.deleted?(@count)) 
      return true
    end
  end
  return false
end

#scoreObject



36
37
38
# File 'lib/ferret/search/match_all_docs_query.rb', line 36

def score() 
  return 1.0
end

#skip_to(target) ⇒ Object



40
41
42
43
# File 'lib/ferret/search/match_all_docs_query.rb', line 40

def skip_to(target) 
  @count = target - 1
  return next?
end