Module: Elasticated::ConditionsBuilder
- Includes:
- BlockEvaluation
- Included in:
- BooleanClause, QueryConditions
- Defined in:
- lib/elasticated/conditions_builder.rb
Instance Method Summary collapse
- #between(field, min_value, max_value, opts = {}) ⇒ Object
- #boolean(&block) ⇒ Object (also: #bool)
- #custom(body) ⇒ Object
- #equal(field, values, opts = {}) ⇒ Object (also: #terms)
- #exists(field, opts = {}) ⇒ Object
- #greater_equal(field, value, opts = {}) ⇒ Object (also: #ge, #gte)
- #greater_than(field, value, opts = {}) ⇒ Object (also: #gt)
- #less_equal(field, value, opts = {}) ⇒ Object (also: #le, #lte)
- #less_than(field, value, opts = {}) ⇒ Object (also: #lt)
- #missing(field, opts = {}) ⇒ Object
- #nested(path, opts = {}, &block) ⇒ Object
- #script(script, params = {}) ⇒ Object
- #wildcard(field, value, opts = {}) ⇒ Object
- #with(field, opts = {}) ⇒ Object
Methods included from BlockEvaluation
Instance Method Details
#between(field, min_value, max_value, opts = {}) ⇒ Object
31 32 33 |
# File 'lib/elasticated/conditions_builder.rb', line 31 def between(field, min_value, max_value, opts={}) add Conditions::RangeCondition.new field, { lte: max_value, gte: min_value }, opts end |
#boolean(&block) ⇒ Object Also known as: bool
67 68 69 70 71 |
# File 'lib/elasticated/conditions_builder.rb', line 67 def boolean(&block) boolean_children = QueryConditions.new boolean_children.evaluate block add boolean_children end |
#custom(body) ⇒ Object
6 7 8 |
# File 'lib/elasticated/conditions_builder.rb', line 6 def custom(body) add Conditions::CustomCondition.new body end |
#equal(field, values, opts = {}) ⇒ Object Also known as: terms
10 11 12 |
# File 'lib/elasticated/conditions_builder.rb', line 10 def equal(field, values, opts={}) add Conditions::TermsCondition.new field, [*values], opts end |
#exists(field, opts = {}) ⇒ Object
23 24 25 |
# File 'lib/elasticated/conditions_builder.rb', line 23 def exists(field, opts={}) add Conditions::ExistsCondition.new field, opts end |
#greater_equal(field, value, opts = {}) ⇒ Object Also known as: ge, gte
40 41 42 |
# File 'lib/elasticated/conditions_builder.rb', line 40 def greater_equal(field, value, opts={}) add Conditions::RangeCondition.new field, { gte: value }, opts end |
#greater_than(field, value, opts = {}) ⇒ Object Also known as: gt
35 36 37 |
# File 'lib/elasticated/conditions_builder.rb', line 35 def greater_than(field, value, opts={}) add Conditions::RangeCondition.new field, { gt: value }, opts end |
#less_equal(field, value, opts = {}) ⇒ Object Also known as: le, lte
51 52 53 |
# File 'lib/elasticated/conditions_builder.rb', line 51 def less_equal(field, value, opts={}) add Conditions::RangeCondition.new field, { lte: value }, opts end |
#less_than(field, value, opts = {}) ⇒ Object Also known as: lt
46 47 48 |
# File 'lib/elasticated/conditions_builder.rb', line 46 def less_than(field, value, opts={}) add Conditions::RangeCondition.new field, { lt: value }, opts end |
#missing(field, opts = {}) ⇒ Object
27 28 29 |
# File 'lib/elasticated/conditions_builder.rb', line 27 def missing(field, opts={}) add Conditions::MissingCondition.new field, opts end |
#nested(path, opts = {}, &block) ⇒ Object
57 58 59 60 61 |
# File 'lib/elasticated/conditions_builder.rb', line 57 def nested(path, opts={}, &block) inner_conditions = self.class.new inner_conditions.evaluate block add Conditions::NestedCondition.new path, inner_conditions, opts end |
#script(script, params = {}) ⇒ Object
63 64 65 |
# File 'lib/elasticated/conditions_builder.rb', line 63 def script(script, params={}) add Conditions::ScriptCondition.new script, params end |
#wildcard(field, value, opts = {}) ⇒ Object
15 16 17 |
# File 'lib/elasticated/conditions_builder.rb', line 15 def wildcard(field, value, opts={}) add Conditions::WildcardCondition.new field, value, opts end |
#with(field, opts = {}) ⇒ Object
19 20 21 |
# File 'lib/elasticated/conditions_builder.rb', line 19 def with(field, opts={}) add Conditions::WildcardCondition.new field, '*', opts end |