Module: Rooftop::AlgoliaSearch::PostIndexing::ClassMethods
- Defined in:
- lib/rooftop/algolia_search/post_indexing.rb
Instance Attribute Summary collapse
-
#search_fields ⇒ Object
readonly
Returns the value of attribute search_fields.
-
#search_index_name ⇒ Object
Returns the value of attribute search_index_name.
-
#search_index_settings ⇒ Object
Returns the value of attribute search_index_settings.
Instance Method Summary collapse
- #add_search_field(field, options = nil) ⇒ Object
- #add_search_fields(*fields) ⇒ Object
- #clear_index! ⇒ Object
- #deindex_entities(entities) ⇒ Object (also: #deindex_entity)
- #reindex_all ⇒ Object
- #reindex_entities(entities) ⇒ Object (also: #reindex_entity)
- #search_index ⇒ Object
- #setup_index_name! ⇒ Object
- #setup_index_settings! ⇒ Object
Instance Attribute Details
#search_fields ⇒ Object (readonly)
Returns the value of attribute search_fields.
16 17 18 |
# File 'lib/rooftop/algolia_search/post_indexing.rb', line 16 def search_fields @search_fields end |
#search_index_name ⇒ Object
Returns the value of attribute search_index_name.
16 17 18 |
# File 'lib/rooftop/algolia_search/post_indexing.rb', line 16 def search_index_name @search_index_name end |
#search_index_settings ⇒ Object
Returns the value of attribute search_index_settings.
16 17 18 |
# File 'lib/rooftop/algolia_search/post_indexing.rb', line 16 def search_index_settings @search_index_settings end |
Instance Method Details
#add_search_field(field, options = nil) ⇒ Object
41 42 43 44 45 |
# File 'lib/rooftop/algolia_search/post_indexing.rb', line 41 def add_search_field(field, = nil) @search_fields ||= [] @search_fields << [field, ].compact end |
#add_search_fields(*fields) ⇒ Object
36 37 38 39 |
# File 'lib/rooftop/algolia_search/post_indexing.rb', line 36 def add_search_fields(*fields) @search_fields ||= [] fields.each {|f| @search_fields << f} end |
#clear_index! ⇒ Object
69 70 71 |
# File 'lib/rooftop/algolia_search/post_indexing.rb', line 69 def clear_index! search_index.clear_index end |
#deindex_entities(entities) ⇒ Object Also known as: deindex_entity
62 63 64 65 |
# File 'lib/rooftop/algolia_search/post_indexing.rb', line 62 def deindex_entities(entities) entities = Array.wrap(entities) search_index.delete_objects(entities.collect(&:id)) end |
#reindex_all ⇒ Object
51 52 53 |
# File 'lib/rooftop/algolia_search/post_indexing.rb', line 51 def reindex_all reindex_entities(all.to_a) end |
#reindex_entities(entities) ⇒ Object Also known as: reindex_entity
55 56 57 58 |
# File 'lib/rooftop/algolia_search/post_indexing.rb', line 55 def reindex_entities(entities) entities = Array.wrap(entities) search_index.add_objects(entities.collect(&:to_search_index_parameters)) end |
#search_index ⇒ Object
74 75 76 |
# File 'lib/rooftop/algolia_search/post_indexing.rb', line 74 def search_index @search_index ||= Algolia::Index.new(@search_index_name) end |
#setup_index_name! ⇒ Object
31 32 33 |
# File 'lib/rooftop/algolia_search/post_indexing.rb', line 31 def setup_index_name! @search_index_name ||= self.to_s.underscore end |
#setup_index_settings! ⇒ Object
27 28 29 |
# File 'lib/rooftop/algolia_search/post_indexing.rb', line 27 def setup_index_settings! search_index.set_settings(@search_index_settings) unless @search_index_settings.nil? end |