Class: Daedal::Queries::ConstantScoreQuery

Inherits:
Query
  • Object
show all
Defined in:
lib/daedal/queries/constant_score_query.rb

Instance Method Summary collapse

Methods inherited from Query

#to_json

Constructor Details

#initialize(options = {}) ⇒ ConstantScoreQuery

you must require *one of* query or filter in order for this to be valid



14
15
16
17
18
19
# File 'lib/daedal/queries/constant_score_query.rb', line 14

def initialize(options={})
  super options
  if query.nil? && filter.nil?
    raise "Must give a query or a filter"
  end
end

Instance Method Details

#to_hashObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/daedal/queries/constant_score_query.rb', line 21

def to_hash
  result = {constant_score: {boost: boost}}
  if !query.nil?
    result[:constant_score][:query] = query.to_hash
  elsif !filter.nil?
    result[:constant_score][:filter] = filter.to_hash
  end

  result
end