Search code examples
mysqlpostgresqlsphinxthinking-sphinx

Error running ThinkingSphinx with PostgreSQL


I used to have thinking-sphinx up and running with mySQL. Now, I migrate to PostgreSQL. However, my thinking-sphinx is still configured for mySQL, so got the following error:

    /Users/name/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:251:in `require': no such file to load -- mysql2 (LoadError)

I trace back to thinking_sphinx.rb file in Users/name/.rvm/gems/thinking-sphinx-3.0.1/lib and found the following:

if RUBY_PLATFORM == 'java'
  require 'java'
  require 'jdbc/mysql'
else
  require 'mysql2'
end

How do I force thinking-sphinx to accept pgsql? Alternatively, do I need to uninstall thinking-sphinx and Sphinx completely and install them with configuration for pgsql?


Solution

  • From https://github.com/pat/thinking-sphinx/issues/413#issuecomment-11912232

    Thinking Sphinx v3 communicates with Sphinx using SphinxQL - which essentially means Sphinx behaves like a MySQL server. Hence, the mysql2 gem is required for sending queries to Sphinx.

    So add this to you Gemfile

    gem 'mysql2'