Method: Sunspot::Rails::Searchable::ClassMethods#solr_index_orphans
- Defined in:
- lib/sunspot/rails/searchable.rb
#solr_index_orphans ⇒ Object
Return the IDs of records of this class that are indexed in Solr but do not exist in the database. Under normal circumstances, this should never happen, but this method is provided in case something goes wrong. Usually you will want to rectify the situation by calling #clean_index_orphans or #reindex
Returns
- Array
-
Collection of IDs that exist in Solr but not in the database
258 259 260 261 262 263 264 265 |
# File 'lib/sunspot/rails/searchable.rb', line 258 def solr_index_orphans count = self.count indexed_ids = solr_search_ids { paginate(:page => 1, :per_page => count) }.to_set all(:select => 'id').each do |object| indexed_ids.delete(object.id) end indexed_ids.to_a end |