Class: Stretchy::Queries::BoolQuery
- Defined in:
- lib/stretchy/queries/bool_query.rb
Constant Summary
Constants included from Utils::Contract
Utils::Contract::ASSERTIONS, Utils::Contract::DECAY_FUNCTIONS, Utils::Contract::DISTANCE_FORMAT
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ BoolQuery
constructor
A new instance of BoolQuery.
- #to_search ⇒ Object
Methods included from Utils::Contract
included, #require_one, #validate!
Constructor Details
#initialize(options = {}) ⇒ BoolQuery
Returns a new instance of BoolQuery.
7 8 9 10 11 |
# File 'lib/stretchy/queries/bool_query.rb', line 7 def initialize( = {}) @must = Array([:must]) @must_not = Array([:must_not]) @should = Array([:should]) end |
Instance Method Details
#to_search ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/stretchy/queries/bool_query.rb', line 13 def to_search json = {} json[:must] = @must.map(&:to_search) if @must.any? json[:must_not] = @must_not.map(&:to_search) if @must_not.any? json[:should] = @should.map(&:to_search) if @should.any? { bool: json } end |