Skip to content

Instantly share code, notes, and snippets.

@intarstudents
Last active December 17, 2015 09:59
Show Gist options
  • Save intarstudents/5591431 to your computer and use it in GitHub Desktop.
Save intarstudents/5591431 to your computer and use it in GitHub Desktop.
Compiling Sphinx

MySQL includes

$ sudo aptitude install libmysql++-dev libmysqlclient15-dev checkinstall

Install Sphinx

$ wget http://sphinxsearch.com/files/sphinx-2.1.1-beta.tar.gz
$ tar zxvf sphinx-2.1.1-beta.tar.gz
$ cd sphinx-2.1.1-beta
$ ./configure --enable-id64
$ make
$ make install

Configuration

index indexname
{
	type = rt
	path = /storage/indexname/indexname

	rt_field = cat
	rt_field = lang
	rt_attr_timestamp = pdate

	charset_type = utf-8
	dict = keywords
	#rt_mem_limit = 512M

	charset_table = 0..9, A..Z->a..z, &, -, _, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F, U+100->U+101, U+101, U+10C->U+10D, U+10D, U+112->U+113, U+113, U+122->U+123, U+123, U+12A->U+12B, U+12B, U+136->U+137, U+137, U+13B->U+13C, U+13C, U+145->U+146, U+146, U+160->U+161, U+161, U+16A->U+16B, U+16B, U+17D->U+17E, U+17E
}

indexer
{
	mem_limit = 1024M
	write_buffer = 12M
}

searchd
{
	listen = 12002
	listen = 12003:mysql41
	log = /storage/log/log.log
	query_log = /storage/log/query.log
	read_timeout = 5
	max_children = 0
	pid_file = /storage/log/searchd.pid
	max_matches = 100000 # max results to return
	seamless_rotate = 1
	preopen_indexes = 1
	unlink_old 	= 1
	workers = threads
	binlog_path = /storage/log
	dist_threads = 4
	compat_sphinxql_magics 	= 1
}

Create directories

$ mkdir /storage/{indexname,logs} -p

Sphinx instance

$ searchd -c /path/to/sphinx.conf # start
$ searchd -c /path/to/sphinx.conf --stop # stop
$ mysql -h 127.0.0.1 -P 12003 # for inserting items
mysql> SHOW TABLES;
mysql> DESC indexname;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment