Sergey Nikolaev
March 24, 2011 ・ Sphinx
Minimal Sphinx configuration to play with Sphinx
If you want to start learning Sphinx or see how some its feature works the following simplest Sphinx configuration might be useful:
source min
{
type = mysql
sql_host = localhost
sql_user = root
sql_pass =
sql_db = test
sql_query = select 1, 'cat' union select 2, 'dog'
}
index idx_min
{
path = idx
source = min
}
searchd
{
listen = 9306:mysql41
log = sphinx.log
pid_file = sphinx.pid
binlog_path =
}
It contains almost nothing, but only those things Sphinx cannot work without. Those are:
-
Section "source" to fetch data from mysql. In this case we don't even fetch real data from mysql, but just use mysql interface having the data defined right in the config ("select 1, 'cat' union select 2, 'dog'"). It will create 2 documents in Sphinx: one containing word "cat", another one with word "dog", the ids are 1 and 2 respectively.
-
Section "index" to create index based on the above source, it contains only reference to the source ("source = min") and path to the index ("path = idx"). Once you build this index files idx.* will be created in the dir you start 'indexer' from.
-
Section "searchd" to tell Sphinx what ports it should be listening ("listen = 9307:mysql41" which means that SphinxQL should be used to talk to Sphinx on this port), what log it should use ("log = sphinx.log") and where it should save its process id ("pid_file = sphinx.pid")
Here's an example of using this config:
-
Indexing:
-
Using 'search' tool to find some results:
-
Starting 'searchd' and fetching results using mysql client:
Enjoy playing with Sphinx!
- Sphinx
- Code
- Basics