Module: ElasticRecord::Relation::SearchMethods

Included in:
ElasticRecord::Relation
Defined in:
lib/elastic_record/relation/search_methods.rb

Instance Method Summary collapse

Instance Method Details

#as_elasticObject



117
118
119
# File 'lib/elastic_record/relation/search_methods.rb', line 117

def as_elastic
  build_search.as_elastic
end

#extending(*modules, &block) ⇒ Object



113
114
115
# File 'lib/elastic_record/relation/search_methods.rb', line 113

def extending(*modules, &block)
  clone.extending!(*modules, &block)
end

#extending!(*modules, &block) ⇒ Object



104
105
106
107
108
109
110
111
# File 'lib/elastic_record/relation/search_methods.rb', line 104

def extending!(*modules, &block)
  modules << Module.new(&block) if block_given?

  self.extending_values += modules.flatten
  extend(*extending_values)

  self
end

#facet(facet_or_name, options = {}) ⇒ Object



91
92
93
# File 'lib/elastic_record/relation/search_methods.rb', line 91

def facet(facet_or_name, options = {})
  clone.facet! facet_or_name, options = {}
end

#facet!(name_or_facet, options = {}) ⇒ Object



81
82
83
84
85
86
87
88
89
# File 'lib/elastic_record/relation/search_methods.rb', line 81

def facet!(name_or_facet, options = {})
  if name_or_facet.is_a?(String)
    self.facet_values += [arelastic.facet[name_or_facet].terms(name_or_facet, options)]
  else
    self.facet_values += [name_or_facet]
  end

  self
end

#filter(*args) ⇒ Object



42
43
44
# File 'lib/elastic_record/relation/search_methods.rb', line 42

def filter(*args)
  clone.filter!(*args)
end

#filter!(*args) ⇒ Object



37
38
39
40
# File 'lib/elastic_record/relation/search_methods.rb', line 37

def filter!(*args)
  self.filter_values += args.flatten
  self
end

#limit(value) ⇒ Object



55
56
57
# File 'lib/elastic_record/relation/search_methods.rb', line 55

def limit(value)
  clone.limit!(value)
end

#limit!(value) ⇒ Object



50
51
52
53
# File 'lib/elastic_record/relation/search_methods.rb', line 50

def limit!(value)
  self.limit_value = value
  self
end

#negate(*args) ⇒ Object



46
47
48
# File 'lib/elastic_record/relation/search_methods.rb', line 46

def negate(*args)
  filter args.map { |arg| arelastic.filter.not arg }
end

#offset(value) ⇒ Object



64
65
66
# File 'lib/elastic_record/relation/search_methods.rb', line 64

def offset(value)
  clone.offset! value
end

#offset!(value) ⇒ Object



59
60
61
62
# File 'lib/elastic_record/relation/search_methods.rb', line 59

def offset!(value)
  self.offset_value = value
  self
end

#order(*args) ⇒ Object



100
101
102
# File 'lib/elastic_record/relation/search_methods.rb', line 100

def order(*args)
  clone.order! *args
end

#order!(*args) ⇒ Object



95
96
97
98
# File 'lib/elastic_record/relation/search_methods.rb', line 95

def order!(*args)
  self.order_values += args.flatten
  self
end

#query(value) ⇒ Object



33
34
35
# File 'lib/elastic_record/relation/search_methods.rb', line 33

def query(value)
  clone.query! value
end

#query!(value) ⇒ Object



28
29
30
31
# File 'lib/elastic_record/relation/search_methods.rb', line 28

def query!(value)
  self.query_value = value
  self
end

#select(*args, &block) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/elastic_record/relation/search_methods.rb', line 73

def select(*args, &block)
  if block_given?
    to_a.select(&block)
  else
    clone.select! *args
  end
end

#select!(*args) ⇒ Object



68
69
70
71
# File 'lib/elastic_record/relation/search_methods.rb', line 68

def select!(*args)
  self.select_values += args.flatten
  self
end