Sphinx for Rotation\Tube sites

Basically script uses mysql to search DB, but on large DB mysql too slow. + it doesnt use morphology.

Sphinx (sphinxsearch.com) - is an open source full text search server, designed from the ground up with performance, relevance (aka search quality), and integration simplicity in mind. It faster then Mysql and deliver better quality of results.

Setup

source scj
{
	type					= mysql

	sql_host				= localhost
	sql_user				= scj_mysql_login
	sql_pass				= scj_mysql_password
	sql_db					= scj_db
	sql_port				= 3306	# optional, default is 3306

	sql_query				= SELECT id, date, tags, alt, description, duration, sponsor_id, rgroup FROM rot_galleries as g \
							  JOIN rot_gallery_stats AS gs ON g.id = gs.thumb_id WHERE status = 1 and gs.best_thumb = 'yes' and rgroup != 0
        // for version 49
	//sql_query				= SELECT id, UNIX_TIMESTAMP(activation_date) as date, tags, alt, description, duration, sponsor_id, rgroup FROM rot_galleries as g \
	//						  JOIN rot_gallery_stats AS gs ON g.id = gs.thumb_id JOIN rot_gallery_data AS gd ON gd.gallery_md5 = g.gallery_md5 WHERE status = 1 and gs.best_thumb = 'yes' and rgroup != 0

	sql_attr_timestamp		= date
	sql_attr_uint		    = duration
	sql_attr_uint		    = sponsor_id
	sql_attr_uint		    = rgroup

	sql_query_info			        = SELECT * FROM rot_galleries WHERE id=$id
}


index scj_index
{
	source					= scj
	path					= /path_to_data/scj/sphinx/scj_index
	docinfo					= extern
	morphology                              = stem_en # or stem_ru for example
}


You have to edit here:

scj_mysql_login
scj_mysql_password
scj_db
path_to_data

That's all.

Note if you change DB (add\remove content) - please, run indexer every day to keep it's base up to date.

Add to cron something like (ask admin)

indexer --all --rotate