Skip to content
isohuntto edited this page Dec 19, 2014 · 1 revision

Sphinx installation

Install sphinx

You can get it from here. Site was tested on version 2.1.9.

Add configuration to your sphinx.conf file

source opb_dbconnect {
    type = mysql
    sql_host = YOUR_MYSQL_HOST
    sql_user = YOUR_MYSQL_USERNAME
    sql_pass = YOUR_MYSQL_PASSWORD
    sql_db = YOUR_MYSQL_DATABASE
    sql_port = 3306
    sql_query_pre = SET NAMES utf8
}
index opb_common {
    docinfo = extern
    charset_type = utf-8
    charset_table = 0..9, A..Z->a..z, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F
    #min_word_len = 2
    enable_star = 1
    #min_infix_len = 3
    #min_prefix_len = 3
    expand_keywords = 1
    index_exact_words = 1
    morphology = stem_enru
    min_stemming_len = 4
    dict = keywords
    ngram_len = 1
    ngram_chars = U+4E00..U+9FBB, U+3400..U+4DB5, U+20000..U+2A6D6, U+FA0E, U+FA0F, U+FA11, U+FA13, U+FA14, U+FA1F, U+FA21, U+FA23, U+FA24, U+FA27, U+FA28, U+FA29, U+3105..U+312C, U+31A0..U+31B7, U+3041, U+3043, U+3045, U+3047, U+3049, U+304B, U+304D, U+304F, U+3051, U+3053, U+3055, U+3057, U+3059, U+305B, U+305D, U+305F, U+3061, U+3063, U+3066, U+3068, U+306A..U+306F, U+3072, U+3075, U+3078, U+307B, U+307E..U+3083, U+3085, U+3087, U+3089..U+308E, U+3090..U+3093, U+30A1, U+30A3, U+30A5, U+30A7, U+30A9, U+30AD, U+30AF, U+30B3, U+30B5, U+30BB, U+30BD, U+30BF, U+30C1, U+30C3, U+30C4, U+30C6, U+30CA, U+30CB, U+30CD, U+30CE, U+30DE, U+30DF, U+30E1, U+30E2, U+30E3, U+30E5, U+30E7, U+30EE, U+30F0..U+30F3, U+30F5, U+30F6, U+31F0, U+31F1, U+31F2, U+31F3, U+31F4, U+31F5, U+31F6, U+31F7, U+31F8, U+31F9, U+31FA, U+31FB, U+31FC, U+31FD, U+31FE, U+31FF, U+AC00..U+D7A3, U+1100..U+1159, U+1161..U+11A2, U+11A8..U+11F9, U+A000..U+A48C, U+A492..U+A4C6
    preopen = 1
}
source opbtorrents : opb_dbconnect {
    sql_query_range = SELECT MIN(id), MAX(id) FROM torrents
    sql_range_step = 100000
    sql_query = SELECT tr.id AS id, tr.hash, tr.name, tr.tags, tr.category_id, UNIX_TIMESTAMP(tr.created_at) AS created_at, tr.size, tr.downloads_count, tr.seeders, tr.leechers, tr.torrent_status, \
        tr.visible_status, \
        tr.files_count AS files_count \
        FROM `torrents` AS tr \
        WHERE tr.id BETWEEN $start AND $end \
        GROUP BY tr.id
        sql_field_string        = name
        sql_field_string        = tags
        sql_attr_uint           = category_id
        sql_attr_timestamp      = created_at
        sql_attr_bigint         = size
        sql_attr_uint           = downloads_count
        sql_attr_uint           = seeders
        sql_attr_uint           = leechers
        sql_attr_uint           = torrent_status
        sql_attr_uint           = visible_status
        sql_attr_uint           = files_count
        sql_attr_string         = hash
}
index opbtorrents : opb_common {
    source = opbtorrents
    path = /var/lib/sphinx/opbtorrents2
    min_infix_len = 3
    dict = keywords
}
indexer {
    mem_limit = 512M
}
searchd {
    listen = 3312
    listen = 3306:mysql41
    log = /var/log/sphinx/searchd.log
    read_timeout = 5
    max_children = 0
    pid_file = /var/run/sphinx/searchd.pid
    max_matches = 100000
    seamless_rotate = 0
    preopen_indexes = 1
    unlink_old = 1
    workers = threads
    binlog_path = /var/lib/sphinx
}

Create index

Command is here: indexer --all

Start your sphinx

Done! =)