<p>I would like to do full-text searching of data in my Ruby on Rails application.  What options exist?</p>

[{'answer_id': 47660, 'author': 'marcospereira', 'author_id': 4600, 'author_profile': 'https://Stackoverflow.com/users/4600', 'pm_score': 3, 'selected': False, 'text': '<p>You can use Ferret (which is Lucene written in Ruby). It integrates seamless with Rails using the acts_as_ferret mixin. Take a look at "<a href="http://wiki.rubyonrails.org/rails/pages/HowToIntegrateFerretWithRails" rel="nofollow noreferrer">How to Integrate Ferret With Rails</a>". A alternative is <a href="http://www.slashdotdash.net/articles/2007/08/06/rails-searching-with-sphinx" rel="nofollow noreferrer">Sphinx</a>.</p>\n'}, {'answer_id': 47668, 'author': 'John Topley', 'author_id': 1450, 'author_profile': 'https://Stackoverflow.com/users/1450', 'pm_score': 3, 'selected': False, 'text': '<p>I can recommend Sphinx. Ryan Bates has a great <a href="http://railscasts.com/episodes/120-thinking-sphinx" rel="noreferrer">screencast</a> on using the Thinking Sphinx plugin to create a full-text search solution.</p>\n'}, {'answer_id': 47680, 'author': 'sock', 'author_id': 4028, 'author_profile': 'https://Stackoverflow.com/users/4028', 'pm_score': 5, 'selected': True, 'text': '<p>There are several options available and each have different strengths and weaknesses. If you would like to add full-text searching, it would be prudent to investigate each a little bit and try them out to see how well it works for you in your environment.</p>\n\n<p>MySQL has built-in support for full-text searching.  It has online support meaning that when new records are added to the database, they are automatically indexed and will be available in the search results. The <a href="http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html" rel="nofollow noreferrer">documentation</a> has more details.</p>\n\n<p><a href="http://code.google.com/p/acts-as-tsearch/" rel="nofollow noreferrer"><code>acts_as_tsearch</code></a> offers a wrapper for similar built-in functionality for recent versions of <a href="http://www.postgresql.org/docs/8.3/static/textsearch.html" rel="nofollow noreferrer">PostgreSQL</a></p>\n\n<p>For other databases you will have to use other software.</p>\n\n<p><a href="http://lucene.apache.org/" rel="nofollow noreferrer">Lucene</a> is a popular search provider written in Java. You can use Lucene through its search server <a href="http://lucene.apache.org/solr/" rel="nofollow noreferrer">Solr</a> with Rails using <a href="http://acts-as-solr.rubyforge.org/" rel="nofollow noreferrer"><code>acts_as_solr</code></a>.</p>\n\n<p>If you don\'t want to use Java, there is a port of Lucene to Ruby called <a href="http://ferret.davebalmain.com/trac/wiki" rel="nofollow noreferrer">Ferret</a>. Support for Rails is added using the <a href="http://projects.jkraemer.net/acts_as_ferret/wiki" rel="nofollow noreferrer"><code>acts_as_ferret</code></a> plugin.</p>\n\n<p><a href="http://xapian.org/" rel="nofollow noreferrer">Xapian</a> is another good option and is supported in Rails using the <a href="http://github.com/frabcus/acts_as_xapian/wikis" rel="nofollow noreferrer"><code>acts_as_xapian</code></a> plugin.</p>\n\n<p>Finally, my preferred choice is <a href="http://www.sphinxsearch.com/" rel="nofollow noreferrer">Sphinx</a> using the <a href="http://blog.evanweaver.com/files/doc/fauna/ultrasphinx/files/README.html" rel="nofollow noreferrer">Ultrasphinx</a> plugin. It is extremely fast and has many options on how to index and search your databases, but is no longer being actively maintained.</p>\n\n<p>Another plugin for Sphinx is <a href="http://ts.freelancing-gods.com/" rel="nofollow noreferrer">Thinking Sphinx</a> which has a lot of positive <a href="http://www.williambharding.com/blog/rails/rails-thinking-sphinx-plugin-full-text-searching-thats-cooler-than-a-polar-bears-toenails/" rel="nofollow noreferrer">feedback</a>. It is a little easier to get started using Thinking Sphinx than Ultrasphinx. I would suggest investigating both plugins to determine which fits better with your project.</p>\n'}, {'answer_id': 75505, 'author': 'Otto', 'author_id': 9594, 'author_profile': 'https://Stackoverflow.com/users/9594', 'pm_score': 1, 'selected': False, 'text': '<p>I\'ve been compiling a <a href="https://stackoverflow.com/questions/73527/whats-the-best-option-for-searching-in-ruby-on-rails">list of the various Ruby on Rails search options in this other question</a>.  I\'m not sure how, or if to combine our questions.</p>\n'}, {'answer_id': 121287, 'author': 'MattMcKnight', 'author_id': 8136, 'author_profile': 'https://Stackoverflow.com/users/8136', 'pm_score': 1, 'selected': False, 'text': "<p>It depends on what database you are using. I would recommend using Solr as it offers up a lot of nice options. The downside is you have to run a separate process for it.  I have used Ferret as well, but found it to be less stable in terms of multi-threaded access to the index.  I haven't tried Sphinx because it only works with MySQL and Postgres.</p>\n"}, {'answer_id': 634421, 'author': 'iros', 'author_id': 2108922, 'author_profile': 'https://Stackoverflow.com/users/2108922', 'pm_score': 1, 'selected': False, 'text': '<p>Just a note for future reference: Ultra Sphinx is no longer being maintained. Thinking sphinx is its replacement. Although it lacks several features at this time like excerpting which Ultra sphinx had, it makes up for it in other features.</p>\n'}, {'answer_id': 1351946, 'author': 'user116218', 'author_id': 116218, 'author_profile': 'https://Stackoverflow.com/users/116218', 'pm_score': 1, 'selected': False, 'text': '<p>I would recommend acts_as_ferret as I am using it for Scrumpad project at work. The indexing can be done as a separate process which ensures that while re-indexing we can still use our application. This can reduce the downtime of website. Also the searching is much faster. You can search through multiple model at a time and have your results sorted out by the fields you prefer.</p>\n'}, {'answer_id': 59523303, 'author': 'Joshua Pinter', 'author_id': 293280, 'author_profile': 'https://Stackoverflow.com/users/293280', 'pm_score': 2, 'selected': False, 'text': '<h1>Two main options, depending on what you\'re after.</h1>\n<h3>1) Full Text Indexing and <code>MATCH() AGAINST()</code>.</h3>\n<p>If you\'re just looking to do a fast search against a few text columns in your table, you can simply use a full text index of those columns and use <code>MATCH() AGAINST()</code> in your queries.</p>\n<ol>\n<li><p>Create the full text index in a migration file:</p>\n<pre><code> add_index :table, :column, type: :fulltext\n</code></pre>\n</li>\n<li><p>Query using that index:</p>\n<pre><code> where( &quot;MATCH( column ) AGAINST( ? )&quot;, term )\n</code></pre>\n</li>\n</ol>\n<h3>2) <a href="https://www.elastic.co/" rel="nofollow noreferrer">ElasticSearch</a> and <a href="https://github.com/ankane/searchkick" rel="nofollow noreferrer">Searchkick</a></h3>\n<p>If you\'re looking for a full blown search indexing solution that allows you to search for any column in any of your records while still being lightning quick, take a look at <a href="https://www.elastic.co/" rel="nofollow noreferrer">ElasticSearch</a> and <a href="https://github.com/ankane/searchkick" rel="nofollow noreferrer">Searchkick</a>.</p>\n<p><a href="https://www.elastic.co/" rel="nofollow noreferrer">ElasticSearch</a> is the indexing and search engine.</p>\n<p><a href="https://github.com/ankane/searchkick" rel="nofollow noreferrer">Searchkick</a> is the integration library with Rails that makes it very easy to index your records and search them.</p>\n<p><a href="https://github.com/ankane/searchkick#getting-started" rel="nofollow noreferrer">Searchkick\'s README</a> does a fantastic job at explaining how to get up and running and to fine tune your setup, but here is a little snippet:</p>\n<ol>\n<li><p>Install and start ElasticSearch.</p>\n<pre><code> brew install elasticsearch\n brew services start elasticsearch\n</code></pre>\n</li>\n<li><p>Add <code>searchkick</code> gem to your bundle:</p>\n<pre><code> bundle add searchkick --strict\n</code></pre>\n<p><em>The <code>--strict</code> option just tells Bundler to use an exact version in your Gemfile, which I highly recommend.</em></p>\n</li>\n<li><p>Add <code>searchkick</code> to a model you want to index:</p>\n<pre><code> class MyModel &lt; ApplicationRecord\n   searchkick\n end\n</code></pre>\n</li>\n<li><p>Index your records.</p>\n<pre><code> MyModel.reindex\n</code></pre>\n</li>\n<li><p>Search your index.</p>\n<pre><code> matching_records = MyModel.search( &quot;term&quot; )\n</code></pre>\n</li>\n</ol>\n'}]
['https://Stackoverflow.com/questions/47656', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4028/']