joshuabowers/search_magic — Issue #22: Rake task to rebuild the searchable values for all SearchMagic documents
Author: joshuabowers
Created: 2012-01-18 06:10:17+00:00
State: open

A searchable document's data is only searchable once the document's @searchable_values@ array has information within it. This array is automatically managed for each document upon saving. However, for documents which existed prior to having SearchMagic bundled in, no values will be in @searchable_values@. A simple solution would be to do something like the following:

```ruby
class Foo
include Mongoid::Document
include SearchMagic
# ...
end

# ...

Foo.all.each {|foo| foo.save!}
```

However, why go to that (admittedly simple) amount of trouble? Why not just have a rake task to do this for you?

```
rake search_magic:rebuild
```