#!/usr/bin/env python from localsettings import * config = """ source addons { type = mysql sql_host = %s sql_user = %s sql_pass = %s sql_db = %s sql_query_pre = SET NAMES utf8 sql_query_pre = SET SESSION query_cache_type=OFF sql_query_pre = LOCK TABLE sphinx_index_feed READ sql_query = \ SELECT \ id, IF(type=4 AND app_id IS NULL,99, app_id) AS app, \ addon_id, authors, tags, type, \ addon_versions, status, locale, \ locale_ord, averagerating, weeklydownloads, totaldownloads, \ inactive, name, name AS name_ord, homepage, description, summary, \ developercomments, \ IF (type=4,9999999999999,max_ver) AS max_ver, \ IF (type=4,0,min_ver) AS min_ver, \ created, modified \ FROM sphinx_index_feed sql_query_post = UNLOCK TABLES sql_attr_uint = addon_id sql_attr_uint = app sql_attr_str2ordinal = name_ord sql_attr_uint = type sql_attr_uint = status sql_attr_uint = weeklydownloads sql_attr_uint = totaldownloads sql_attr_uint = locale_ord sql_attr_bigint = max_ver sql_attr_bigint = min_ver sql_attr_str2ordinal = locale sql_attr_float = averagerating sql_attr_bool = inactive sql_attr_str2ordinal = homepage sql_attr_timestamp = created sql_attr_timestamp = modified sql_attr_multi = uint category from query; \ SELECT a.id AS id, ac.category_id AS category \ FROM addons_categories ac, sphinx_index_feed a \ WHERE a.addon_id = ac.addon_id sql_attr_multi = uint tag from query; \ SELECT a.id AS id, t.tag_id AS tag \ FROM users_tags_addons t, sphinx_index_feed a \ WHERE t.addon_id = a.addon_id sql_attr_multi = uint platform from query; \ SELECT a.id AS id, platform_id AS platform \ FROM versions v, applications_versions av, files f, sphinx_index_feed a \ WHERE av.version_id=v.id \ AND f.version_id=v.id \ AND a.addon_id = v.addon_id \ AND f.status > 1 sql_query_info = SELECT * FROM sphinx_index_feed WHERE id=$id } """ % (MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_NAME,) config = config + """ index addons { source = addons path = %s/catalog # morphology = stem_en # symlink sphinx-wordforms.txt to this location: wordforms = /opt/local/etc/sphinx-wordforms.txt # Firebug will get indexed as Firebug, Firebu, Fireb, Fire, Fir - equally # We can enable star if necessary. min_infix_len = 3 #enable_star = 1 } """ % (CATALOG_PATH) config = config + """ searchd { listen = 3312 listen = localhost:3307:mysql41 log = %s/searchd.log query_log = %s/query.log pid_file = %s/searchd.pid } """ % ((LOG_PATH,)*3) print config