rails - Search Controller

I'm getting ready to build search capabilities into my app. I want the search to have the ability to span multiple models.

I'm thinking about adding a search controller which would then decide which models to search based on settings etc...

What do you think? Does a search controller sound right or is there something open-source I should be thinking about?



You have a couple of options for search in ruby world like

  1. Sphinx
  2. Ferret
  3. Solr
  4. Endeca

Going through the documentation of heroku, heroku suggests with solr which is an awesome search engine. http://docs.heroku.com/websolr and http://docs.heroku.com/full-text-search details more information about that. We chose solr for search in one of our projects and we used sunspot_rails which nicely integrates with your models and reindexes when your content changes. We used the gem sunspot_rails from http://github.com/outoftime/sunspot which is recommended by heroku too.

Caveat though is that heroku's file system is read only and does not allow you to run arbitrary processes, so you have to choose one like websolr(starts from 20$ a month) or spawning your own amazon ec2 instance and do the indexing there. Since heroku is also running on amazon ec2, the latency is very very less.

Getting back to the alternatives, Ferret is known to crash/corrupt indexes often in production. Sphinx is not supported by heroku. Endeca is damn expensive, you gotta spend most of your budget just even to get basic results.

If you are using Postgres, you can use the pg_search gem

I would say avoid rolling your own search "engine" unless you have a very specific need that cannot be met by something like Sphinx (also read this)

Category:ruby on rails Time:2010-10-26 Views:1

Related post

  • Are there any cases in which Rails overwrites controller instance variables on render :partial? 2009-06-27

    Are there any cases in which Rails overwrites controller instance variables on a render :partial call performed in a template? For example, let's say we have: controller def my_action @widget = Widget.find(params[:id]) end view my_action.html.erb Hi

  • I simple search controller that stores search history, should I use resource routing or non-resource? 2011-01-14

    I am learning rails and am toying with a simple web-app that integrates with flickr to search photos based on user given criteria and store the query in a search history table. I am seeking the best or 'rails' way of handling this. Should I setup a c

  • Does this Rails 3 Controller method make me look fat? 2010-10-26

    This is a new application, and I have an index method on a Search controller. This also serves as the home page for the application, and I'm trying to decide if I am headed down the wrong path from a design pattern perspective. The method is already

  • How do I use the `--helper` flag in a rails 3 controller generator? 2010-12-10

    The documentation from rails generate controller says: [--helper] # Indicates when to generate helper # Default: true Now, it doesn't specify how to indicate a value. So, since the default is true, that means that excluding it won't indicate false, b

  • Running an external .rb file from within a rails 3 controller? 2011-01-10

    I have a rails 3 controller and a very simple ruby (.rb) file in my server index directory. I would like to run the file from within my controller- what is the best way to do this? --------------Solutions------------- You could try load: http://www.r

  • Is it possible to run rails g controller/model in a test mode, to see what will happen? 2011-02-25

    I want to know before hand exactly what files a generator will create, is it possible to run it in a 'test' mode so it just lists the files and doesn't actually create it? --------------Solutions------------- Sure, you can use the -p option ctcherry$

  • how do I reverse rails g controller some_namespace::some_controller? 2011-03-24

    I'm trying to remove a namespaced controller in command line, how can I achieve this ? Thanks --------------Solutions------------- rails destroy controller some_namespace::some_controller I just ran it on my system, here is the output: rails destroy

  • Ruby on Rails generate controller giving an error 2011-04-28

    I'm currently trying to generate a controller in rails with the command: rails generate controller Songs index upload delete But I get the error: /Users/lucasdobbins/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/commands.rb:15:in `require':

  • Rails Model/Controller Structure 2012-03-13

    I've recently just gotten into programming with ruby on rails, and I've been having trouble grasping how exactly I should be structuring and organizing all my code, specifically exactly how to differentiate what certain scaffolds/models/controllers s

  • Rails define controller as root controller 2012-03-22

    I know that in Rails (3.2.2), I can route requests to / with the following in routes.rb: root :to => 'main_pages#index' How can I make MainPages the default controller for all index actions? For example, if I used rails g controller to make a new

  • Ruby on Rails plural (controller) and singular (model) convention - explanation 2012-04-09

    As per Ruby on Rails convention, controller names get pluralized while model names are singular. Example : a Users controller, but a User model. rails generate controller Users rails generate model User name:string email:string Now open migration fil

  • why rails generate controller is not working? 2012-04-13

    I am trying to run this in the terminal: rails generate controller welcome index but, there isn't any file created! the process finished with exit code 0 I am using rails 3.2.3 any idea please ? EDIT RUBYGEMS VERSION: 1.8.10 RUBY VERSION: 1.9.3 (2011

  • Ruby on Rails generating controller with existing folder 2013-03-10

    I'm really new at this and I don't want to mess up my current application. I'm currently working on HTML/CSS stuff but I have a little understanding as to how to get things working. I created a new controller by just doing rails generate controller s

  • How to test a search controller action which has filters in Rails with RSpec? 2011-09-16

    We have a bar with filters in almost all of our table-based views in a rails app and we need to test the controller action. An example of the code: def index @users = User. with_status(params[:status]). with_role(params[:role_id]). search(params[:q])

  • Rails search form - directly to top result 2009-08-29

    Does anyone know how to make a search form (in rails) go directly to the first result, rather than a page of results? --------------Solutions------------- Have the results limited to one and redirect to that result's page from your controller.

  • rails search a category for sub categories 2010-04-24

    http://github.com/collectiveidea/awesome_nested_set awesome nested set plugin and currently, if I choose a sub category as my category_id for an item, I can not search by its parent. Category.parent Category.Child I choose Category.child as the categ

  • Unable to get simple ruby on rails Search to work :/ 2010-05-03

    I am new to RoR, any help would be greatly appreciated :) I have a basic scaffolding CRUD app to add customers. I am trying to search by first_name or last_name fields. The error that I am getting is: NoMethodError in Clientes#find You have a nil obj

  • Requiring gem in Rails 3 Controller failing with "Constant Missing" 2010-07-06

    I've seen this asked a few times in other threads, but none of the answers seem to apply. Environment: Rails 3 amazon/ecs gem from jugend. The lone file is here: http://github.com/jugend/amazon-ecs/blob/master/lib/amazon/ecs.rb my gemfile has: gem 'a

  • Rails Search with optional parameters? 2010-12-18

    How would I do a search on a database when the search can provide many optional parameters such as ID, Zip, City, and State? These can either have values or be blank entirely. How would I make a rails query like that? --------------Solutions---------

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 0.472 (s). 13 q(s)