common {
    plugin_dir = C:/sphinx/bin/plugins
}

source ygg {
  type = mysql
  sql_host = 127.0.0.1
  sql_user = root
  sql_pass = 
  sql_db = ygg
  sql_port = 3306
}

source torrents : ygg {
  sql_query_pre = SET NAMES utf8
  sql_query = SELECT T.id , T.seed , T.leech , T.completed, T.comments_count, U.settings, U.nickname , T.publish_date, T.size , T.name, T.is_exclusivity, T.options , T.name AS sortable_name , T.state , T.state AS sortable_state , T.description , \
  T.files, T.parent_category , T.category FROM torrents T JOIN users U ON T.uploader = U.id
  
  sql_attr_json = settings
  sql_attr_json = options
  sql_attr_string = sortable_name
  sql_attr_uint = category
  sql_attr_uint = publish_date
  sql_attr_uint = sortable_state
  sql_attr_bigint = size
  sql_attr_uint = seed
  sql_attr_uint = completed
  sql_attr_uint = leech
  sql_attr_uint = comments_count
  sql_attr_uint = is_exclusivity
  sql_attr_uint = parent_category
}


source users : ygg {
  sql_query_pre = SET NAMES utf8
  sql_query_pre = SELECT @last_user_indexed := max_id FROM sphinx_index_meta WHERE index_name = 'sph_idx_users'
  sql_query = SELECT id, email AS mail, email, last_activity_date, join_date, downloaded, uploaded, nickname AS nick, nickname, pass FROM users

  # Update du compteur
  sql_query_pre = SELECT @max_user_id :=  max(id) FROM users  
  sql_query_pre = REPLACE INTO sphinx_index_meta (index_name, max_id, last_update) VALUES ('sph_idx_users', @max_user_id, UNIX_TIMESTAMP());

  sql_attr_bigint = last_activity_date
  sql_attr_uint = join_date
  sql_attr_bigint = downloaded
  sql_attr_bigint = uploaded
  sql_attr_string = email
  sql_attr_string = nickname
}

source users_delta : users {
 sql_query_pre = SET NAMES utf8
 sql_query_pre = SELECT @last_user_indexed := max_id FROM sphinx_index_meta WHERE index_name = 'sph_idx_users'

 # Update du compteur
 sql_query_pre = SELECT @max_user_id :=  max(id) FROM users
 sql_query_pre = REPLACE INTO sphinx_index_meta (index_name, max_id) VALUES ('sph_idx_users', @max_user_id);

 sql_query = SELECT id, email AS mail, email, last_activity_date, join_date, downloaded, uploaded, nickname AS nick, nickname, pass FROM users WHERE id > @last_user_indexed
}

source stats : ygg {
  sql_query_pre = SET NAMES utf8
  sql_query = SELECT fid, HEX(info_hash) AS info_hash, completed, leechers, seeders FROM xbt_files
  sql_attr_uint = completed
  sql_attr_uint = seeders
  sql_attr_uint = leechers
}

index torrents {
  source = torrents
  path = C:/sphinx/data/torrents
  mlock = 0
  morphology=libstemmer_french, stem_en
  html_strip = 1
  charset_table = 0..9, A..Z->a..z, a..z, \
  U+C0->a, U+C1->a, U+C2->a, U+C3->a, U+C4->a, U+C5->a, U+C6->a, \
  U+E0->a, U+E1->a, U+E2->a, U+E3->a, U+E4->a, U+E5->a, U+E6->a, U+C7->c,U+E7->c,\
  U+C8->e, U+C9->e, U+CA->e, U+CB->e, U+E8->e, U+E9->e, U+EA->e, U+EB->e, \
  U+CC->i, U+CD->i, U+CE->i, U+CF->i, U+EC->i, U+ED->i, U+EE->i, U+EF->i, \
  U+00C8->e, U+00C9->e, U+00CA->e, U+00CB->e, U+00E8->e, U+00E9->e, U+00EA->e, \
  U+00EB->e, U+0112->e, U+0113->e, U+0114->e, U+0115->e, U+0116->e, U+0117->e, \
  U+0118->e, U+0119->e, U+011A->e, U+011B->e, U+018E->e, U+0190->e, U+01DD->e, \
  U+0204->e, U+0205->e, U+0206->e, U+0207->e, U+0228->e, U+0229->e, U+0246->e, \
  U+0247->e, U+0258->e, U+025B->e, U+025C->e, U+025D->e, U+025E->e, U+029A->e, \
  U+1D07->e, U+1D08->e, U+1D31->e, U+1D32->e, U+1D49->e, U+1D4B->e, U+1D4C->e, \
  U+1D92->e, U+1D93->e, U+1D94->e, U+1D9F->e, U+1E14->e, U+1E15->e, U+1E16->e, \
  U+1E17->e, U+1E18->e, U+1E19->e, U+1E1A->e, U+1E1B->e, U+1E1C->e, U+1E1D->e, \
  U+1EB8->e, U+1EB9->e, U+1EBA->e, U+1EBB->e, U+1EBC->e, U+1EBD->e, U+1EBE->e, \
  U+1EBF->e, U+1EC0->e, U+1EC1->e, U+1EC2->e, U+1EC3->e, U+1EC4->e, U+1EC5->e, \
  U+1EC6->e, U+1EC7->e, U+2091->e,
}


index users {
  source = users
  path = C:/sphinx/data/users
} 

index users_delta {
  source = users_delta
  path = C:/sphinx/data/users_delta
}

index stats {
  source = stats
  path = C:/sphinx/data/stats
}

searchd {
	listen			= 9312
	listen			= 9306:mysql41
    log = C:/sphinx/log/searchd.log
    query_log = C:/sphinx/log/query.log
    pid_file = C:/sphinx/searchd.pid
    #data_dir = C:/sphinx/data
    query_log_format = sphinxql
}
