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.



268
269
270
# File 'lib/sunspot/rails/searchable.rb', line 268

def index
  Sunspot.index(self)
end

#index!Object

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



275
276
277
# File 'lib/sunspot/rails/searchable.rb', line 275

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.



286
287
288
# File 'lib/sunspot/rails/searchable.rb', line 286

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!()



297
298
299
300
# File 'lib/sunspot/rails/searchable.rb', line 297

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