Module: ElasticRecord::SearchMethods

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

Instance Method Summary collapse

Instance Method Details

#as_elasticObject



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

def as_elastic
  build_search.as_elastic
end

#extending(*modules, &block) ⇒ Object



108
109
110
# File 'lib/elastic_record/relation/search_methods.rb', line 108

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

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



99
100
101
102
103
104
105
106
# File 'lib/elastic_record/relation/search_methods.rb', line 99

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



86
87
88
# File 'lib/elastic_record/relation/search_methods.rb', line 86

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

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



76
77
78
79
80
81
82
83
84
# File 'lib/elastic_record/relation/search_methods.rb', line 76

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



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

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

#filter!(*args) ⇒ Object



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

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

#limit(value) ⇒ Object



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

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

#limit!(value) ⇒ Object



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

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

#offset(value) ⇒ Object



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

def offset(value)
  clone.offset! value
end

#offset!(value) ⇒ Object



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

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

#order(*args) ⇒ Object



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

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

#order!(*args) ⇒ Object



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

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

#query(value) ⇒ Object



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

def query(value)
  clone.query! value
end

#query!(value) ⇒ Object



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

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

#select(*args, &block) ⇒ Object



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

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

#select!(*args) ⇒ Object



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

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