Sphinx connection error on search results page in Ruby on Rails application
I have a RoR application with a Posgresql database. I am trying to customize a search function using Sphinx as my search engine and the Thinking Sphinx gem. I have installed sphinx with mysql and postgresql support, thinking about the sphinx v3 gem and its dependencies.
Command
rake ts: index
makes mistakes. The magazine says I have 20 documents indexed (all my Post model entries). Then I tried to create a controller and view the search results page. Here's the controller search action
def search
@query = Riddle::Query.escape(params[:q])
@posts = Post.search(@query)
end
And when i try to use @posts variable in search view
local: 3000 / search q = hi
I have the following error.
ThinkingSphinx :: ConnectionError in main # search
Error connecting to Sphinx via MySQL protocol. Error connecting to Sphinx via MySQL protocol. Unable to connect to MySQL server at "127.0.0.1" (61) - SELECT * FROM
post_core
WHERE MATCH ('hello') ANDsphinx_deleted
= 0 LIMIT 0, 20; SHOW META
source to share
I generally got stuck and faced the same error. Finally, I found that I did not install "Sphinx" on my local system with this command,
sudo apt-get update
sudo apt-get install sphinxsearch
You can find more details about installation here
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-sphinx-on-ubuntu-14-04
Make sure you also have to install "mysql-server" on your system to create a connection.
Also I looked that @blelump's answer was my second step. You must include these gems in order to work with the sphinx.
Then move on to @pat's answer, this is my final step. When you have installed sphinx, it will start the service, but you need to stop running the service,
rake ts:index
rake ts:rebuild
Here to go with SPHINX.
source to share