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



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

def as_elastic
  build_search.as_elastic
end

#extending(*modules, &block) ⇒ Object



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

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

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



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

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



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

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

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



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

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



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

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

#limit!(value) ⇒ Object



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

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

#offset(value) ⇒ Object



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

def offset(value)
  clone.offset! value
end

#offset!(value) ⇒ Object



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

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

#order(*args) ⇒ Object



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

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

#order!(*args) ⇒ Object



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

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



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

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

#select!(*args) ⇒ Object



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

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