Class: Arelastic::Builders::Filter

Inherits:
Struct
  • Object
show all
Defined in:
lib/arelastic/builders/filter.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fieldObject

Returns the value of attribute field

Returns:

  • (Object)

    the current value of field



3
4
5
# File 'lib/arelastic/builders/filter.rb', line 3

def field
  @field
end

Class Method Details

.[](field) ⇒ Object



5
6
7
# File 'lib/arelastic/builders/filter.rb', line 5

def [](field)
  new(field)
end

.ids(*ids) ⇒ Object



9
10
11
# File 'lib/arelastic/builders/filter.rb', line 9

def ids *ids
  Arelastic::Filters::Ids.new ids.flatten
end

.not(expr) ⇒ Object



13
14
15
# File 'lib/arelastic/builders/filter.rb', line 13

def not expr
  Arelastic::Filters::Not.new expr
end

Instance Method Details

#eq(other) ⇒ Object



18
19
20
# File 'lib/arelastic/builders/filter.rb', line 18

def eq other
  Arelastic::Filters::Term.new field, other
end

#existsObject



47
48
49
# File 'lib/arelastic/builders/filter.rb', line 47

def exists
  Arelastic::Filters::Exists.new field
end

#gt(other) ⇒ Object



59
60
61
# File 'lib/arelastic/builders/filter.rb', line 59

def gt other
  range 'gt' => other
end

#gteq(other) ⇒ Object



55
56
57
# File 'lib/arelastic/builders/filter.rb', line 55

def gteq other
  range 'gte' => other
end

#in(other, options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/arelastic/builders/filter.rb', line 26

def in other, options = {}
  case other
  when Range
    if other.exclude_end?
      range 'gte' => other.begin, 'lt' => other.end
    else
      range 'gte' => other.begin, 'lte' => other.end
    end
  else
    Arelastic::Filters::Terms.new field, other, options
  end
end

#lt(other) ⇒ Object



67
68
69
# File 'lib/arelastic/builders/filter.rb', line 67

def lt other
  range 'lt' => other
end

#lteq(other) ⇒ Object



63
64
65
# File 'lib/arelastic/builders/filter.rb', line 63

def lteq other
  range 'lte' => other
end

#missing(options = {}) ⇒ Object



51
52
53
# File 'lib/arelastic/builders/filter.rb', line 51

def missing(options = {})
  Arelastic::Filters::Missing.new field, options
end

#not_eq(other) ⇒ Object



22
23
24
# File 'lib/arelastic/builders/filter.rb', line 22

def not_eq other
  self.class.not eq(other)
end

#not_in(other, options = {}) ⇒ Object



39
40
41
# File 'lib/arelastic/builders/filter.rb', line 39

def not_in other, options = {}
  self.class.not self.in(other, options)
end

#prefix(other) ⇒ Object



43
44
45
# File 'lib/arelastic/builders/filter.rb', line 43

def prefix other
  Arelastic::Filters::Prefix.new field, other
end