Class: Ferret::Search::TermQuery
- Defined in:
- lib/ferret/search/term_query.rb
Overview
A Query that matches documents containing a @term.
This may be combined with other terms with a BooleanQuery.
Defined Under Namespace
Classes: TermWeight
Instance Attribute Summary collapse
-
#term ⇒ Object
readonly
Returns the value of attribute term.
Attributes inherited from Query
Instance Method Summary collapse
- #create_weight(searcher) ⇒ Object
-
#eql?(other) ⇒ Boolean
(also: #==)
Returns true iff
ois equal to this. - #extract_terms(terms) ⇒ Object
-
#hash ⇒ Object
Returns a hash code value for this object.
-
#initialize(t) ⇒ TermQuery
constructor
Constructs a query for the @query.term
t. -
#to_s(field = nil) ⇒ Object
Prints a user-readable version of this query.
Methods inherited from Query
#combine, #merge_boolean_queries, #rewrite, #similarity, #weight
Constructor Details
#initialize(t) ⇒ TermQuery
Constructs a query for the @query.term t.
93 94 95 96 |
# File 'lib/ferret/search/term_query.rb', line 93 def initialize(t) super() @term = t end |
Instance Attribute Details
#term ⇒ Object (readonly)
Returns the value of attribute term.
6 7 8 |
# File 'lib/ferret/search/term_query.rb', line 6 def term @term end |
Instance Method Details
#create_weight(searcher) ⇒ Object
98 99 100 |
# File 'lib/ferret/search/term_query.rb', line 98 def create_weight(searcher) return TermWeight.new(self, searcher) end |
#eql?(other) ⇒ Boolean Also known as: ==
Returns true iff o is equal to this.
116 117 118 119 |
# File 'lib/ferret/search/term_query.rb', line 116 def eql?(other) return false if not other.instance_of?(TermQuery) return (@boost == other.boost and @term == other.term) end |
#extract_terms(terms) ⇒ Object
102 103 104 |
# File 'lib/ferret/search/term_query.rb', line 102 def extract_terms(terms) terms << @term end |
#hash ⇒ Object
Returns a hash code value for this object.
123 124 125 |
# File 'lib/ferret/search/term_query.rb', line 123 def hash() return @boost.hash ^ @term.hash end |
#to_s(field = nil) ⇒ Object
Prints a user-readable version of this query.
107 108 109 110 111 112 113 |
# File 'lib/ferret/search/term_query.rb', line 107 def to_s(field = nil) buffer = "" buffer << "#{@term.field}:" if field != @term.field buffer << "#{@term.text}" buffer << "^#{@boost}" if @boost != 1.0 return buffer end |