Module: Railstank::Search::ClassMethods
- Defined in:
- lib/railstank.rb
Instance Attribute Summary collapse
-
#index_name ⇒ Object
Returns the value of attribute index_name.
-
#search_index ⇒ Object
Returns the value of attribute search_index.
Instance Method Summary collapse
Instance Attribute Details
#index_name ⇒ Object
Returns the value of attribute index_name.
21 22 23 |
# File 'lib/railstank.rb', line 21 def index_name @index_name end |
#search_index ⇒ Object
Returns the value of attribute search_index.
21 22 23 |
# File 'lib/railstank.rb', line 21 def search_index @search_index end |
Instance Method Details
#has_indextank(class_index_name, options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/railstank.rb', line 23 def has_indextank(class_index_name,={}) indextank_index_name = class_index_name.to_s define_method "index_name" do indextank_index_name end define_method "search_index" do Railstank.client.indexes indextank_index_name end define_method "index_class_name" do [:index_class_name].present? ? [:index_class_name].to_s.underscore : self.class.name.underscore end @index_name = indextank_index_name @search_index = Railstank.client.indexes indextank_index_name end |
#isearch(field, options = {}) ⇒ Object
41 42 43 44 45 |
# File 'lib/railstank.rb', line 41 def isearch(field,={}) fetch_id_type = [:fetch] results = search_index.search(field,)["results"] result_ids = results.map{ |result| result[fetch_id_type] }.uniq end |