I am trying to implement a search function on a model based on several attributes. I want the user to be able to specify which attributes to filter. This would be very similar to any e-commerce site such as Amazon.com
For example, a user can filter based on - author - rating - category
Any advice would be greatly appreciated!
This approach is often called faceted search. Try:
,
http://railscasts.com/episodes/111-advanced-search-form-revised
, , - .
Solr , Sunspot Ruby/Rails Solr.
, :
# Posts that match 'pizza' returning counts for each :author_id search = Post.search do fulltext "pizza" facet :author_id end search.facet(:author_id).rows.each do |facet| puts "Author #{facet.value} has #{facet.count} pizza posts!" end
Sunspot Rails Solr save.
save
, , Solr, ElasticSearch, : https://github.com/fortytools/forty_facets