#
# Maccms Sphinx Config File
#

# 创建统计表
# CREATE TABLE `sph_counter` ( `id` bigint(11) unsigned NOT NULL AUTO_INCREMENT, `counter_id` bigint(20) unsigned NOT NULL,`max_doc_id` bigint(20) unsigned NOT NULL,PRIMARY KEY (`id`)) 

indexer
{
	mem_limit		= 32M
	write_buffer 	= 64M
}

searchd
{
	listen			= 9312
	listen			= 9306:mysql41
	log				= {$SERVER_APP}/index/searchd.log
	query_log		= {$SERVER_APP}/index/query.log
	read_timeout	= 5
	max_children	= 0
	pid_file		= {$SERVER_APP}/index/searchd.pid
	seamless_rotate	= 1
	preopen_indexes	= 1
	unlink_old		= 1
	#workers		= threads # for RT to work
	binlog_path		= {$SERVER_APP}/index/binlog
}


# -------- maccms 全量更新 start --------

source mac_vod
{
	type = mysql
	sql_host = 127.0.0.1
	sql_user = maccms
	sql_pass = maccms
   	sql_db = maccms
	sql_port = 3306
	sql_query_range = SELECT min(vod_id), max(vod_id) FROM mac_vod
	sql_query_pre = SET NAMES UTF8
	sql_query_pre  = SET SESSION query_cache_type=OFF
	sql_query = SELECT vod_id as id, vod_name, vod_tag, vod_class, vod_actor, vod_director, vod_time,vod_time_add FROM mac_vod WHERE vod_status=1 and vod_id>=$start AND vod_id<=$end
	sql_range_step = 1000


	sql_attr_uint = vod_id
	sql_attr_timestamp	= vod_time
	sql_attr_timestamp	= vod_time_add
	sql_field_string = vod_name

	sql_query_post = UPDATE sph_counter SET max_doc_id=(SELECT MAX(vod_id) FROM mac_vod) where counter_id=1
}

index mac_vod
{
	source			= mac_vod
	path			= {$SERVER_APP}/index/db/maccms/index

	min_word_len = 2
	html_strip = 1
    ngram_len = 1
    ngram_chars = U+3000..U+2FA1F
}

# --------  maccms 全量更新 end --------


# --------  maccms 增量更新 start --------


source mac_vod_delta : mac_vod
{
	sql_query_pre = SET NAMES utf8

	sql_query_range = SELECT (SELECT max_doc_id FROM `sph_counter` where counter_id=1) as min, (SELECT max(vod_id) FROM mac_vod) as max
    
    sql_query = SELECT vod_id as id, vod_name, vod_tag, vod_class, vod_actor, vod_director, vod_time,vod_time_add FROM mac_vod WHERE vod_status=1 and vod_id>=$start AND vod_id<=$end

    sql_query_post = UPDATE sph_counter SET max_doc_id=(SELECT MAX(vod_id) FROM mac_vod) where counter_id=1
}

index mac_vod_delta : mac_vod
{
	source			= mac_vod_delta
	path			= {$SERVER_APP}/index/db/maccms_delta/index

	min_word_len = 2
	html_strip = 1
    ngram_len = 1
    ngram_chars = U+3000..U+2FA1F
}

# --------  maccms 增量更新 end --------