Starting from now , next few post gonna by about sphinx.It's pretty awesome full-text search engine.
I'm only gonna said that on table containing ~40 milion record (with partitions, right indexing and so on) classic mysql full-text search last about 10-15s. When I do this with sphinx it's less than 1s :)
So let's get started ;)
At first I'm gonna show how to install sphinx on Ubuntu/Debian and check is it running properly.
1. Installation:
apt-get install sphinxsearchand that's why I love ubuntu : D
2. Basic elements
Ok, so before we start the party, few words to remember
indexer – a tool for indexing our data sources
searchd - deamon responsible for searching data
search – a command line tool for searching data
searchapi – api for programming languages (in this tutorial we gonna focus on php)
Ok so when we're ready let's see the config file
vim /etc/sphinxsearch/sphinx.conf
source test_src
{
type = mysql
sql_host = localhost
sql_user = myuser
sql_pass = mypass
sql_db = database_name
sql_query = select id,name from history
}
index index_test
{
source = test_src
path = /var/lib/sphinxsearch/data/index_test
docinfo = extern
charset_type = utf-8
}
indexer
{
mem_limit = 32M
}
searchd
{
port = 3312
log = /var/log/searchd/searchd.log
query_log = /var/log/searchd/query.log
pid_file = /var/log/searchd/searchd.pid
}
The typical config contains four parts (search,search,index,indexer). The source,index and indexer are required.
Fileds in source and index par are quite intuitive and should not cause problems.
sql_query defines the query that will give data to our source
docinfo defines how exactly docinfo will be physically stored on disk and RAM
In next part I will show how to prepare basic config and start sphinx deamon.
Brak komentarzy:
Prześlij komentarz