Extremely naive full text search implementation for ActiveRecord based on naive-search by Tomas Jogin (github.com/tjogin/naive-search). Orders results by relevance and gives you detailed info on the search results. Works like this:
Every word in a search query is matched against each text field in your
database using like
.
The returned results are then re-ordered based on how well they match the query and the words the query is made up of.
As opposed to naive-search quest doesn’t re-organize your fields into an index column in your database. Instead it searches after each word in each field that you specify. This may result in huge overhead when searching big databases.
gem install quest
class Person < ActiveRecord::Base quest_on :name, :surname, :description end
This makes the specified fields searchable like so:
Person.quest_for 'my query'
Optionally, you can specify the order and limit of results to return from the database:
class Person < ActiveRecord::Base quest_on :name, :surname, :description, :order => "id desc", :limit => 20 end
Note that the search results will still be re-ordered based on fuzzy “relevance”, this simply specifies how many results to retrieve from the database, and in which order. Also note that small limits combined with broad searches yields terrible results. The default limit is 1 000.
This project uses MIT-LICENSE.