Class: Ferret::Search::Spans::SpanTermQuery::SpanTermEnum
- Inherits:
-
Ferret::Search::Spans::SpansEnum
- Object
- Ferret::Search::Spans::SpansEnum
- Ferret::Search::Spans::SpanTermQuery::SpanTermEnum
- Defined in:
- lib/ferret/search/spans/span_term_query.rb
Instance Method Summary collapse
- #doc ⇒ Object
- #finish ⇒ Object
-
#initialize(query, reader) ⇒ SpanTermEnum
constructor
A new instance of SpanTermEnum.
- #next? ⇒ Boolean
- #skip_to(target) ⇒ Object
- #start ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(query, reader) ⇒ SpanTermEnum
Returns a new instance of SpanTermEnum.
41 42 43 44 45 46 47 48 |
# File 'lib/ferret/search/spans/span_term_query.rb', line 41 def initialize(query, reader) @query = query @positions = reader.term_positions_for(@query.term) @position = -1 @doc = -1 @count = 0 @freq = 0 end |
Instance Method Details
#doc ⇒ Object
86 |
# File 'lib/ferret/search/spans/span_term_query.rb', line 86 def doc() @doc end |
#finish ⇒ Object
88 |
# File 'lib/ferret/search/spans/span_term_query.rb', line 88 def finish() @position + 1 end |
#next? ⇒ Boolean
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ferret/search/spans/span_term_query.rb', line 50 def next? if (@count == @freq) if not @positions.next? @doc = Ferret::Search::Scorer::MAX_DOCS return false end @doc = @positions.doc() @freq = @positions.freq() @count = 0 end @position = @positions.next_position() @count += 1 return true end |
#skip_to(target) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/ferret/search/spans/span_term_query.rb', line 65 def skip_to(target) # are we already at the correct position? if (@doc >= target) return true end if not @positions.skip_to(target) @doc = Ferret::Search::Scorer::MAX_DOCS return false end @doc = @positions.doc() @freq = @positions.freq() @count = 0 @position = @positions.next_position() @count += 1 return true end |
#start ⇒ Object
87 |
# File 'lib/ferret/search/spans/span_term_query.rb', line 87 def start() @position end |
#to_s ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/ferret/search/spans/span_term_query.rb', line 90 def to_s() buffer = "spans(#{@query})@" if @doc < 0 buffer << "START" else if @doc == Ferret::Search::Scorer::MAX_DOCS buffer << "END" else buffer << "#{@doc}-#{@position}" end end return buffer end |