class Daedal::Queries::TermQuery

Public Class Methods

new(options={}) click to toggle source
Calls superclass method
# File lib/daedal/queries/term_query.rb, line 16
def initialize(options={})
  super options

  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

Public Instance Methods

to_hash() click to toggle source
# 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