This plugin adds full text search capabilities and many other nifty features from Apache's Solr to any Rails model. It was based on the first draft by Erik Hatcher.
The current stable release is v0.9 and was released on 06-18-2007.
Please refer to the CHANGE_LOG
For Rails >= 2.1:
script/plugin install git://github.com/mattmatt/acts_as_solr.git
For Rails < 2.1:
cd vendor/plugins
git clone git://github.com/mattmatt/acts_as_solr.git
rm -rf acts_as_solr/.git
Make sure you copy vendor/plugins/acts_as_solr/config/solr.yml to your Rails
application's config directory, when you install via git clone.
- Java Runtime Environment(JRE) 1.5 aka 5.0 http://www.java.com/en/download/index.jsp
- If you have libxml-ruby installed, make sure it's at least version 0.7
Basically everything is configured to work out of the box. You can use rake solr:start and rake solr:stop
to start and stop the Solr web server (an embedded Jetty). If the default JVM options aren't suitable for
your environment, you can configure them in solr.yml with the option jvm_options. There is a default
set for the production environment to have some more memory available for the JVM than the defaults, but
feel free to change them to your liking.
# Just include the line below to any of your ActiveRecord models:
acts_as_solr
# Or if you want, you can specify only the fields that should be indexed:
acts_as_solr :fields => [:name, :author]
# Then to find instances of your model, just do:
Model.find_by_solr(query) #query is a string representing your query
# Please see ActsAsSolr::ActsMethods for a complete info
To test code that uses acts_as_solr you must start a Solr server for the test environment. You can do that with rake solr:start RAILS_ENV=test
acts_as_solr does not perform real-time indexing during tests to make your tests run faster. If you want to assert that your searches are performing correctly, you must build the index within your test like so:
def test_my_search_works
Model.rebuild_index
assert Model.find_by_solr(query)
end
Erik Hatcher: First draft
Thiago Jackiw: Previous developer
Luke Francl: Current developer
Mathias Meyer: Current developer
Check the project website or stop by the Google Group. Send bug reports through Lighthouse.
Released under the MIT license.
The old acts_as_solr homepage is no more. For more up-to-date information, check out the project page of the current mainline on GitHub.