Module: Sunspot::Rails::Searchable::InstanceMethods

Defined in:
lib/sunspot/rails/searchable.rb

Instance Method Summary collapse

Instance Method Details

#indexObject

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.



272
273
274
# File 'lib/sunspot/rails/searchable.rb', line 272

def index
  Sunspot.index(self)
end

#index!Object

Index the model in Solr and immediately commit. See #index



279
280
281
# File 'lib/sunspot/rails/searchable.rb', line 279

def index!
  Sunspot.index!(self)
end

#remove_from_indexObject

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.



290
291
292
# File 'lib/sunspot/rails/searchable.rb', line 290

def remove_from_index
  Sunspot.remove(self)
end

#remove_from_index!Object

Remove the model from the Solr index and commit immediately. See #remove_from_index


FIXME Sunspot should implement remove!()



301
302
303
304
# File 'lib/sunspot/rails/searchable.rb', line 301

def remove_from_index!
  Sunspot.remove(self)
  Sunspot.commit
end