README.rdoc in pollyanna-1.0.3 vs README.rdoc in pollyanna-1.0.4

- old
+ new

@@ -1,59 +1,68 @@ -= Pollyanna - very simple search for your ActiveRecord models - -Pollyanna adds a very simple full text search to your ActiveRecord models. -Before saving, searchable models copy strings relevant to the search into a text column. -Pollyanna finds results for a query using LIKE patterns in SQL. - -We found Pollyanna very useful for search-as-you-type boxes. - -== Example - - class Movie < ActiveRecord::Base - include Pollyanna::Searchable - - def search_text - "#{title} #{year} #{director}" - end - - end - - class MoviesController - - def index - @movies = Movie.search(params[:query]) - end - - end - -== Making a model searchable - -1. Add a text column "search_text" to a model -2. Have the model include <tt>Pollyanna::Searchable</tt> -3. Overwrite <tt>search_text</tt> to define which text is indexed upon saving -4. <tt>Model.search("query goes here")</tt> now gives you a scope for the results of your query. Blank queries return everything. - -== Searching other columns - -If you want to search a column other than <tt>search_text</tt>, you may say <tt>Movie.search(query, :by => "other_column")</tt>. - -== How queries are matched - -- Pollyanna matches partial words, so "oo" matches "foo". -- Multiple words in a query are AND-ed automatically. - -== Installation - -Add the following to your <tt>Initializer.run</tt> block in your <tt>environment.rb</tt>: - config.gem 'pollyanna', :source => 'http://gemcutter.org' -Then do a - sudo rake gems:install - -Alternatively, use - sudo gem sources -a http://gemcutter.org - sudo gem install pollyanna - -== Credits - -Henning Koch - -{www.makandra.de}[http://www.makandra.de/] += Pollyanna - very simple search for your ActiveRecord models + +Pollyanna adds a very simple full text search to your ActiveRecord models. +Before saving, searchable models copy strings relevant to the search into a text column. +Pollyanna finds results for a query using LIKE patterns in SQL. + +We found Pollyanna very useful for search-as-you-type boxes. + +== Example + + class Movie < ActiveRecord::Base + include Pollyanna::Searchable + + def search_text + "#{title} #{year} #{director}" + end + + end + + class MoviesController + + def index + @movies = Movie.search(params[:query]) + end + + end + +== Making a model searchable + +1. Add a text column "search_text" to a model +2. Have the model include <tt>Pollyanna::Searchable</tt> +3. Overwrite <tt>search_text</tt> to define which text is indexed upon saving +4. <tt>Model.search("query goes here")</tt> now gives you a scope for the results of your query. Blank queries return everything. + +== Searching other columns + +If you want to search a column other than <tt>search_text</tt>, you may say <tt>Movie.search(query, :by => "other_column")</tt>. + +== How queries are matched + +- Pollyanna matches partial words, so "oo" matches "foo". +- Multiple words in a query are AND-ed automatically. + + +== Installation + +Pollyanna is a gem, which you can install with + sudo gem install pollyanna + +In Rails 2, add the following to your <tt>environment.rb</tt>: + config.gem 'pollyanna' + +In Rails 3, add the following to your <tt>Gemfile</tt>: + gem 'pollyanna' + + +== Rails 3 compatibility + +We cannot guarantee Rails 3 compatibility at this point, but we will upgrade the gem when Rails 3 is released. + + +== Credits + +Henning Koch + +{makandra.com}[http://makandra.com/] + +{gem-session.com}[http://gem-session.com/]