SPHINX with PHP and MySQL



Hope you guys are doing good!

First let me tell you Why Sphinx is more faster than MySQL. Cuz Sphinx will search in Document format where as MySql search in table format. Now, how exactly it will work MySQL with Sphinx?

1. First you have to Download Sphinx-2.2.1-beta-win32.zip or Sphinx-2.2.1-beta-win32-pgsql.php.
FYR, http://sphinxsearch.com/downloads/beta/

2. Then you have to extract the files in C:/Sphinx

3. Copy your  sphinx.conf.in file and paste it under bin folder and rename it to sphinx.conf.

4.  Now open command prompt by pressing Windows -> cmd

5. Now you have to create service

C:/sphinx/bin > searchd --install --config c:/sphinx/bin/sphinx.conf --servicename SphinxSearch

6. Then you have to create Log file under C:/Sphinx/log

7. Create PID file under log "searchd.pid"

8. Now its time to start the SphinxSearch server

Go to Control panel -> Administrative tools -> Services -> SphinxSearch --Rightclick-> Properties -> Start type Make it as "Manual" -> Now again Right click -> Start.

9. Its done You have installed Sphinx in your local system Successfully.

Now its time to configure in your Sphinx Conf file.

 --------------------------------------------------

Open Your Sphinx.conf file which is under C:/Sphinx/bin

Here you will find

1. Source -> has connection with MySQL and the Query to be executed.

2. Index -> is to Call Source and the Path of data files. Note here you can also mention your Search Pattern

3. Indexer -> is Memory limit

4. Searchd -> Its a Search Daemon part where you have to give Port number to listen, path for Log and Query log, PID file and Binlog_path.

Now its time to create indexers by executing searchd in Command prompt.

-------------------------------------------------------------------------

Open your CMD.

C:/sphinx/bin > indexers --rotate

C:/sphinx/bin > indexers --all

C:/sphinx/bin > searchd --config c:/sphinx/bin/sphinx.conf

[Now you have started Search d service in Server side]

Note to stop the searchd service you have to use following command,

C:/sphinx/bin > searchd --stop

Best Example to learn Sphinx  Please refer the below article,
http://www.ibm.com/developerworks/library/os-sphinx/

[In this above tutorial, they have used SphinxQL instead of SphinxClient. And We PHP developers, i would recommend to go with SphinxQL since we can run the server and code it in our own way :) ]

Hope you guys are enjoyed this tutorial! Please comment if you have any doubts or clarification!! :)



Comments

Popular posts from this blog

Ghostscript Installation and Configuration in Windows 7

Joomla - Get user id