one of the easiest ways to connect your rails app with sphinx.
It is used to connect your Active Record with Sphinx search and it is easy to use and fast to install.

  • Install Sphinx: Add this to Gemfile
gem 'mysql2', '~> 0.5.2'
gem 'thinking-sphinx'
  • Run bundle command
bundle install
  • For passing the indexing parameter, create ‘app/indices/modelname_index.rb’

    Let’s do this with Spree Search. Here we are taking the example of the Product  Model of Spree, Follow these steps:
  1. Create an index file in ‘app/indices/product_index.rb, add the indexing parameters.
ThinkingSphinx::Index.define 'spree/product', :with => :real_time do
indexes name, :sortable => true

2.  Run the command to index and start the Sphinx:

rake ts:stop
rake ts:index
rake ts:start
rake ts:rebuild (stops, re-index, and start)

3. Let’s search for Product with Sphinx:

# To query a product model
q = 'Search Product Name'
products =

For more reference:

This is one of the easiest ways to enhance the Sphinx with Spree E-commerce service. By using this, it will boost the speed of your searching and the server response time of the application.