Searchville and ActsBasicallySearchable
So, you may notice that I just added a search box which will search posts, and maybe comments in the future. This was the first time I've really written a search engine, and it was kind of fun. I initially wanted to use the MySQL FULLTEXT search with built in relevance ranking (which is awesome), but that didn't really work out for me. I wasn't getting back any results when I was searching with
MATCH(field1, field2) AGAINST 'query'
I think maybe the entire table has to be FULLTEXT... anyone know? Anyway, I ended up using a more basic approach and rolled it into a little plugin I call ActsBasicallySearchable. This is my first plugin, so any feedback is appreciated. Basically you just choose which fields you want to search in an ActiveRecord model, and it will return a collection of results, ranked by the frequency of the keywords in those fields.
acts_basically_searchable :title, :body
end
And to search, just say:
Download ActsBasicallySearchable
Comments