Module: Elasticated::ConditionsBuilder

Includes:
Mixins::BlockEvaluation
Included in:
BooleanClause, QueryConditions
Defined in:
lib/elasticated/conditions_builder.rb

Instance Method Summary collapse

Methods included from Mixins::BlockEvaluation

#evaluate

Instance Method Details

#boolean(&block) ⇒ Object Also known as: bool



72
73
74
75
76
# File 'lib/elasticated/conditions_builder.rb', line 72

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

#exists(field, opts = {}) ⇒ Object



27
28
29
# File 'lib/elasticated/conditions_builder.rb', line 27

def exists(field, opts={})
  add Conditions::ExistsCondition.new field, opts
end

#greater_equal(field, value, opts = {}) ⇒ Object Also known as: ge, gte



45
46
47
# File 'lib/elasticated/conditions_builder.rb', line 45

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



40
41
42
# File 'lib/elasticated/conditions_builder.rb', line 40

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



56
57
58
# File 'lib/elasticated/conditions_builder.rb', line 56

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



51
52
53
# File 'lib/elasticated/conditions_builder.rb', line 51

def less_than(field, value, opts={})
  add Conditions::RangeCondition.new field, { lt: value }, opts
end

#missing(field, opts = {}) ⇒ Object



31
32
33
# File 'lib/elasticated/conditions_builder.rb', line 31

def missing(field, opts={})
  add Conditions::MissingCondition.new field, opts
end

#nested(path, opts = {}, &block) ⇒ Object



62
63
64
65
66
# File 'lib/elasticated/conditions_builder.rb', line 62

def nested(path, opts={}, &block)
  inner_conditions = self.class.new
  inner_conditions.evaluate block
  add Conditions::NestedCondition.new path, inner_conditions, opts
end

#nowObject



85
86
87
# File 'lib/elasticated/conditions_builder.rb', line 85

def now
  Elasticated::Enum::NOW
end

#range(field, min_value, max_value, opts = {}) ⇒ Object Also known as: between



35
36
37
# File 'lib/elasticated/conditions_builder.rb', line 35

def range(field, min_value, max_value, opts={})
  add Conditions::RangeCondition.new field, { lte: max_value, gte: min_value }, opts
end

#script(script, params = {}) ⇒ Object



68
69
70
# File 'lib/elasticated/conditions_builder.rb', line 68

def script(script, params={})
  add Conditions::ScriptCondition.new script, params
end

#term(field, value, opts = {}) ⇒ Object



10
11
12
# File 'lib/elasticated/conditions_builder.rb', line 10

def term(field, value, opts={})
  add Conditions::TermCondition.new field, value, opts
end

#terms(field, values, opts = {}) ⇒ Object Also known as: equal



14
15
16
# File 'lib/elasticated/conditions_builder.rb', line 14

def terms(field, values, opts={})
  add Conditions::TermsCondition.new field, [*values], opts
end

#wildcard(field, value, opts = {}) ⇒ Object



19
20
21
# File 'lib/elasticated/conditions_builder.rb', line 19

def wildcard(field, value, opts={})
  add Conditions::WildcardCondition.new field, value, opts
end

#with(field, opts = {}) ⇒ Object



23
24
25
# File 'lib/elasticated/conditions_builder.rb', line 23

def with(field, opts={})
  add Conditions::WildcardCondition.new field, '*', opts
end