new_rotation_sphinx
This is an old revision of the document!
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
- Ask admin to setup sphinx
- create folder scj/sphinx
- ask admin to add scj index into sphinx config. Example :
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
}
for version 51
<code>
source scj
{
type = mysql
sql_host = ............
sql_user = .............
sql_pass = ..............
sql_db = ..............
sql_port = 3306 # optional, default is 3306
sql_query = SELECT id, crc32(g.gallery_md5) as gallery_md5_crc, UNIX_TIMESTAMP(activation_date) as date, tags, alt, description, duration, sponsor_id, rgroup, gs.total_ctr, \
g.content_type, (SELECT group_concat(group_id) FROM rot_gal2group as g2gr WHERE g2gr.gal_id = g.id) as categories FROM rot_galleries as g JOIN rot_gallery_stats AS gs ON g.id = gs.thumb_id \
JOIN rot_gallery_info AS gi ON g.gallery_md5 = gi.gallery_md5 \
JOIN rot_gallery_data AS gd ON g.gallery_md5 = gd.gallery_md5 \
WHERE status = 1 and gs.best_thumb = 'yes' and rgroup != 0 and gs.group_id = 0
sql_attr_timestamp = date
sql_attr_uint = duration
sql_attr_uint = sponsor_id
sql_attr_uint = rgroup
sql_attr_float = total_ctr
sql_attr_uint = content_type
sql_attr_uint = gallery_md5_crc
sql_attr_multi = uint categories from field;
sql_query_info = SELECT * FROM rot_galleries WHERE id=$id
}
You have to edit here:
scj_mysql_login scj_mysql_password scj_db path_to_data </code>
- Run indexer (or ask admin to do it)
indexer --all --rotate
- In Rotation - Settings edit sphinx options.
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
new_rotation_sphinx.1416878351.txt.gz · Last modified: (external edit)
