Skip to content
mattmatt edited this page Sep 13, 2010 · 15 revisions

Since the original authors abandoned acts_as_solr a while ago, this has sort of become the mainline branch for new changes. I took Luke Francl’s version, added a few features of my own, and also a new and fast unit test suite that doesn’t test integration with Solr and Rails, but only the functionality itself.

Currently there’s a rework of the plugin in progress on the refactoring branch.

Usage

acts_as_solr comes with an embedded Jetty installation which allows you to run it directly from within your application. The only thing you need to have installed is a Java Development Kit.

To start the server:
rake solr:start

Add an environment as you please, default is development. test/development/production all run on different ports.

To stop the server:
rake solr:stop

In your models, add this line which will by default index all fields in the class:

class User < ActiveRecord::Base
  acts_as_solr
end

See the RDoc for a full list of the available options.

If you’re adding Solr to an existing application, and you want to build an index on your existing data, you can do using the rebuild_solr_reindex method:

User.rebuild_solr_reindex

There’s a rake task to help you get an initial index up and running faster than the above using some more fitting defaults:

rake solr:reindex ONLY=user,article

It also support EXCEPT and START_SERVER (will fire up Solr before indexing). It will delete the existing index first, if you don’t want that, use CLEAR=false. It will optimize the index after it’s done, disable that using OPTIMIZE=false. By default it uses a batch size of 300 before it commits anything to the index, if you want to finetune that number, set BATCH to the number you want.

Contributing

Patches are most welcome of course. If you submit a pull request, please be sure to include tests for your change. If it’s a bigger one, a functional test would be much appreciated.

Documentation

You can find a reasonably up-to-date RDoc on the acts_as_solr website.

Tutorials

Most of these are slightly older, but still valid for the most part.

Community

Drop by the Google Group and ask your questions.

Clone this wiki locally