Class: Daedal::Queries::TermQuery
- Defined in:
- lib/daedal/queries/term_query.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ TermQuery
constructor
A new instance of TermQuery.
- #to_hash ⇒ Object
Methods inherited from Query
Constructor Details
#initialize(options = {}) ⇒ TermQuery
Returns a new instance of TermQuery.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/daedal/queries/term_query.rb', line 16 def initialize(={}) super if value.nil? && term.nil? raise "Must give a value or a term" elsif value && term raise "Use either Value or Term only, but not both" elsif value && boost.nil? raise "Please specified boost" end end |
Instance Method Details
#to_hash ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/daedal/queries/term_query.rb', line 29 def to_hash if boost if value result = {term: {field => {value: value, boost: boost}}} else result = {term: {field => {term: term, boost: boost}}} end else result = {term: {field => term}} end result end |