Class: Daedal::Queries::ConstantScoreQuery
- Defined in:
- lib/daedal/queries/constant_score_query.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ ConstantScoreQuery
constructor
you must require *one of* query or filter in order for this to be valid.
- #to_hash ⇒ Object
Methods inherited from Query
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(={}) super if query.nil? && filter.nil? raise "Must give a query or a filter" end end |
Instance Method Details
#to_hash ⇒ Object
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 |