Module: Sunspot::MongoMapper::Searchable::InstanceMethods
- Defined in:
- lib/sunspot/mongo_mapper/searchable.rb
Class Method Summary collapse
-
.included(base) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#solr_index ⇒ Object
Index the model in Solr.
-
#solr_index! ⇒ Object
Index the model in Solr and immediately commit.
- #solr_more_like_this(*args, &block) ⇒ Object
- #solr_more_like_this_ids(&block) ⇒ Object
-
#solr_remove_from_index ⇒ Object
Remove the model from the Solr index.
-
#solr_remove_from_index! ⇒ Object
Remove the model from the Solr index and commit immediately.
Class Method Details
.included(base) ⇒ Object
:nodoc:
327 328 329 330 331 332 333 334 335 336 |
# File 'lib/sunspot/mongo_mapper/searchable.rb', line 327 def self.included(base) #:nodoc: base.module_eval do alias_method :index, :solr_index unless method_defined? :index alias_method :index!, :solr_index! unless method_defined? :index! alias_method :remove_from_index, :solr_remove_from_index unless method_defined? :remove_from_index alias_method :remove_from_index!, :solr_remove_from_index! unless method_defined? :remove_from_index! alias_method :more_like_this, :solr_more_like_this unless method_defined? :more_like_this alias_method :more_like_this_ids, :solr_more_like_this_ids unless method_defined? :more_like_this_ids end end |
Instance Method Details
#solr_index ⇒ Object
Index the model in Solr. If the model is already indexed, it will be updated. Using the defaults, you will usually not need to call this method, as models are indexed automatically when they are created or updated. If you have disabled automatic indexing (see ClassMethods#searchable), this method allows you to manage indexing manually.
345 346 347 |
# File 'lib/sunspot/mongo_mapper/searchable.rb', line 345 def solr_index Sunspot.index(self) end |
#solr_index! ⇒ Object
Index the model in Solr and immediately commit. See #index
352 353 354 |
# File 'lib/sunspot/mongo_mapper/searchable.rb', line 352 def solr_index! Sunspot.index!(self) end |
#solr_more_like_this(*args, &block) ⇒ Object
375 376 377 378 379 380 |
# File 'lib/sunspot/mongo_mapper/searchable.rb', line 375 def solr_more_like_this(*args, &block) = args. self.class.solr_execute_search() do Sunspot.new_more_like_this(self, *args, &block) end end |
#solr_more_like_this_ids(&block) ⇒ Object
382 383 384 385 386 |
# File 'lib/sunspot/mongo_mapper/searchable.rb', line 382 def solr_more_like_this_ids(&block) self.class.solr_execute_search_ids do solr_more_like_this(&block) end end |
#solr_remove_from_index ⇒ Object
Remove the model from the Solr index. Using the defaults, this should not be necessary, as models will automatically be removed from the index when they are destroyed. If you disable automatic removal (which is not recommended!), you can use this method to manage removal manually.
363 364 365 |
# File 'lib/sunspot/mongo_mapper/searchable.rb', line 363 def solr_remove_from_index Sunspot.remove(self) end |
#solr_remove_from_index! ⇒ Object
Remove the model from the Solr index and commit immediately. See #remove_from_index
371 372 373 |
# File 'lib/sunspot/mongo_mapper/searchable.rb', line 371 def solr_remove_from_index! Sunspot.remove!(self) end |