I am trying to implement a simple search with Thinking Sphinx, but, it doesnt work. I'm going through "A Quick Guide to Getting Setup with Thinking Sphinx", and when I try to use rake ts:index
I get a nasty error:
Generating configuration to /Users/Kuba/Desktop/Rails/black/config/development.sphinx.conf
Sphinx 2.0.6-release (r3473)
Copyright (c) 2001-2012, Andrew Aksyonoff
Copyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com)
using config file '/Users/Kuba/Desktop/Rails/black/config/development.sphinx.conf'...
indexing index 'news_post_core'...
ERROR: index 'news_post_core': sql_connect: Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2) (DSN=mysql://root:***@localhost:3306/black1).
total 0 docs, 0 bytes
total 0.005 sec, 0 bytes/sec, 0.00 docs/sec
total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
total 0 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
I have no idea, what to do with it. My only index is:
ThinkingSphinx::Index.define :news_post, :with => :active_record do
indexes title
end
My database.yml is:
development:
adapter: mysql2
encoding: utf8
database: black1
pool: 5
username: root
password:
test:
adapter: mysql2
encoding: utf8
database: black1
pool: 5
username: root
password:
production:
adapter: mysql2
encoding: utf8
database: black1
pool: 5
username: root
password:
I installed MySQL from the package downloaded from the Oracle website.
The system I'm on is Mountain Lion. I definitely have MySQL server running, it's easy to check in system preferences.
Also, I installed Sphinx through Macports. What might be possible solutions to this?
I'm guessing Sphinx didn't correctly link up with MySQL when you installed it via macports (I generally would recommend homebrew over macports these days).
What happens if you specify a host of 127.0.0.1 in your database.yml file for the appropriate environments? That might convince Sphinx to connect via TCP instead of file sockets.
(Also: are you really using the same database for both development and test environments?)