Sunspot is a Ruby library for expressive, powerful interaction with the Solr search engine. Sunspot is built on top of the RSolr library, which provides a low-level interface for Solr interaction; Sunspot provides a simple, intuitive, expressive DSL backed by powerful features for indexing objects and searching for them.
Here is an example to implement sunspot solr in rails applications.
Add these lines into your Gemfile
Generate a default configuration file:
Start sunspot solr
bundle exec rake sunspot:solr:start # or sunspot:solr:run to start in foreground.
Making objects to search by solr
Solr makes indexes for objects to perform search. To do this follow these steps:
searchable block to the objects you wish to index.
When you make any changes in the
searchable block then run the following command
bundle exec rake sunspot:solr:reindex
You can modify search by these following steps:
withinto search block to apply some conditions.
order_byinto search block to order searched results.
- You can paginate search results by adding
paginateinto search block.
For more details please click here. Enjoy !!!