Class: Stretchy::Builders::MatchBuilder
- Inherits:
-
Object
- Object
- Stretchy::Builders::MatchBuilder
- Defined in:
- lib/stretchy/builders/match_builder.rb
Instance Attribute Summary collapse
-
#must ⇒ Object
Returns the value of attribute must.
-
#must_not ⇒ Object
Returns the value of attribute must_not.
-
#should ⇒ Object
Returns the value of attribute should.
-
#should_not ⇒ Object
Returns the value of attribute should_not.
Instance Method Summary collapse
- #add_matches(field, matches, options = {}) ⇒ Object
- #any? ⇒ Boolean
-
#initialize ⇒ MatchBuilder
constructor
A new instance of MatchBuilder.
- #to_query ⇒ Object
Constructor Details
#initialize ⇒ MatchBuilder
Returns a new instance of MatchBuilder.
7 8 9 10 11 12 |
# File 'lib/stretchy/builders/match_builder.rb', line 7 def initialize @must = QueryBuilder.new @must_not = QueryBuilder.new @should = QueryBuilder.new @should_not = QueryBuilder.new end |
Instance Attribute Details
#must ⇒ Object
Returns the value of attribute must.
5 6 7 |
# File 'lib/stretchy/builders/match_builder.rb', line 5 def must @must end |
#must_not ⇒ Object
Returns the value of attribute must_not.
5 6 7 |
# File 'lib/stretchy/builders/match_builder.rb', line 5 def must_not @must_not end |
#should ⇒ Object
Returns the value of attribute should.
5 6 7 |
# File 'lib/stretchy/builders/match_builder.rb', line 5 def should @should end |
#should_not ⇒ Object
Returns the value of attribute should_not.
5 6 7 |
# File 'lib/stretchy/builders/match_builder.rb', line 5 def should_not @should_not end |
Instance Method Details
#add_matches(field, matches, options = {}) ⇒ Object
18 19 20 |
# File 'lib/stretchy/builders/match_builder.rb', line 18 def add_matches(field, matches, = {}) ().add_matches(field, matches, ) end |
#any? ⇒ Boolean
14 15 16 |
# File 'lib/stretchy/builders/match_builder.rb', line 14 def any? must.any? || must_not.any? || should.any? || should_not.any? end |
#to_query ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/stretchy/builders/match_builder.rb', line 22 def to_query return Stretchy::Queries::MatchAllQuery.new unless any? if use_bool? bool_query else must.to_query.first end end |