Permalink
Browse files

Sphinx mysql2 issue example

  • Loading branch information...
0 parents commit a64b1103fce856a8003c65d5601b422af94c3553 @barttenbrinke committed Oct 10, 2012
4 Gemfile
@@ -0,0 +1,4 @@
+source 'https://rubygems.org'
+
+gem 'mysql2', :git => "https://github.com/brianmario/mysql2.git"
+
15 Gemfile.lock
@@ -0,0 +1,15 @@
+GIT
+ remote: https://github.com/brianmario/mysql2.git
+ revision: f4d004ac5194dec511960cc1f902422ca3cd442c
+ specs:
+ mysql2 (0.3.12b4)
+
+GEM
+ remote: https://rubygems.org/
+ specs:
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ mysql2!
59 README.rdoc
@@ -0,0 +1,59 @@
+== Running Sphinx
+
+```
+brew install sphinx
+searchd --config ./config/sphinx.conf
+```
+Sphinx will now demonize and run in the background
+
+== Connect through mysql-cli
+```
+mysql -u foobar --port 9306 --protocol tcp --host localhost
+```
+Ensure the server number is "Server version: 2.0.4-release (r3135)", otherwise you accidentally connected to Mysql
+```
+SELECT * FROM content_stemmer WHERE MATCH('a'); SHOW META;
+```
+You should be getting meta results like these:
+
+```
++--------+--------+
+| id | weight |
++--------+--------+
+| 920301 | 1636 |
+| 930301 | 1636 |
++--------+--------+
+2 rows in set (0.00 sec)
+
++---------------+-------+
+| Variable_name | Value |
++---------------+-------+
+| total | 2 |
+| total_found | 2 |
+| time | 0.000 |
+| keyword[0] | a |
+| docs[0] | 2 |
+| hits[0] | 2 |
++---------------+-------+
+6 rows in set (0.00 sec)```
+```
+
+== Connect through mysql2 gem
+
+```
+bundle install
+bundle exec irb
+```
+
+In irb enter the following:
+
+```
+require 'mysql2'
+sphinx = Mysql2::Client.new(:host => '127.0.0.1', :port => 9306, :database => 'noop', :username => 'noop', :flags => Mysql2::Client::MULTI_STATEMENTS)
+sphinx_ql_query = "SELECT * FROM content_stemmer WHERE MATCH('test'); SHOW META;"
+results = sphinx.query(sphinx_ql_query).collect{|x| x}
+p sphinx.next_result
+```
+
+sphinx.next_result should be true, which it isnt.
+
23 config/sphinx.conf
@@ -0,0 +1,23 @@
+indexer
+{
+ mem_limit = 128000000
+}
+
+searchd
+{
+ # address = 127.0.0.1
+ # port = 9312
+ listen = 127.0.0.1:9306:mysql41
+ listen = 127.0.0.1:9312
+ log = ./tmp/searchd.log
+ query_log = ./tmp/searchd.query.log
+ pid_file = ./tmp/searchd.pid
+}
+
+index content_stemmer
+{
+ source = content_xml_sphinx
+ path = ./db/sphinx/content_core_stemmer
+ charset_type = utf-8
+ morphology = stem_en
+}
0 db/sphinx/content_core_stemmer.spa
No changes.
BIN db/sphinx/content_core_stemmer.spd
Binary file not shown.
BIN db/sphinx/content_core_stemmer.sph
Binary file not shown.
BIN db/sphinx/content_core_stemmer.spi
Binary file not shown.
0 db/sphinx/content_core_stemmer.spk
No changes.
0 db/sphinx/content_core_stemmer.spl
No changes.
0 db/sphinx/content_core_stemmer.spm
No changes.
1 db/sphinx/content_core_stemmer.spp
@@ -0,0 +1 @@
+
BIN db/sphinx/content_core_stemmer.sps
Binary file not shown.
7 tmp/searchd.log
@@ -0,0 +1,7 @@
+[Wed Oct 10 22:18:11.800 2012] [70258] accepting connections
+[Wed Oct 10 22:24:02.652 2012] [70258] caught SIGTERM, shutting down
+[Wed Oct 10 22:24:02.652 2012] [70258] shutdown complete
+[Wed Oct 10 22:24:38.150 2012] [70574] accepting connections
+[Wed Oct 10 22:26:39.719 2012] [70574] caught SIGTERM, shutting down
+[Wed Oct 10 22:26:39.719 2012] [70574] shutdown complete
+[Wed Oct 10 22:26:46.088 2012] [70727] accepting connections
1 tmp/searchd.pid
@@ -0,0 +1 @@
+70727
5 tmp/searchd.query.log
@@ -0,0 +1,5 @@
+[Wed Oct 10 22:21:10.314 2012] 0.000 sec [ext2/0/ext 0 (0,20)] [content_stemmer] test
+[Wed Oct 10 22:21:18.604 2012] 0.000 sec [ext2/0/ext 2 (0,20)] [content_stemmer] a
+[Wed Oct 10 22:24:45.543 2012] 0.000 sec [ext2/0/ext 2 (0,20)] [content_stemmer] a
+[Wed Oct 10 22:26:51.971 2012] 0.000 sec [ext2/0/ext 2 (0,20)] [content_stemmer] a
+[Wed Oct 10 22:28:12.677 2012] 0.000 sec [ext2/0/ext 0 (0,20)] [content_stemmer] test

0 comments on commit a64b110

Please sign in to comment.