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.



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

def index
  Sunspot.index(self)
end

#index!Object

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



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

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.



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

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



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

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