#
# Discuz Sphinx Config File
#

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
}


source pre_forum_thread
{
	type = mysql
	sql_host = 127.0.0.1
	sql_user = bbs
	sql_pass = bbs
   	sql_db = bbs
	sql_port = 3306
	sql_query_pre = SET NAMES UTF8
	sql_query_pre  = SET SESSION query_cache_type=OFF
	sql_query_pre = REPLACE INTO bbs_common_sphinxcounter SELECT 1, MAX(tid) FROM bbs_forum_thread
	sql_query = SELECT t.tid as id,t.tid,t.subject,t.digest,t.displayorder,t.authorid,t.lastpost,t.special \
			FROM bbs_forum_thread AS t WHERE t.tid>=$start AND t.tid<=$end
	sql_query_range = SELECT (SELECT MIN(tid) FROM bbs_forum_thread),maxid FROM bbs_common_sphinxcounter WHERE indexid=1

	sql_range_step = 5000
	sql_attr_uint = tid

	sql_attr_uint = digest
	sql_attr_uint = displayorder
	sql_attr_uint = authorid
	sql_attr_uint = special
	sql_attr_timestamp =lastpost
}

index pre_forum_thread
{
	source			= pre_forum_thread
	path			= {$SERVER_APP}/index/db/pre_forum_thread/index

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


# threads_minute
source pre_forum_thread_minute : pre_forum_thread
{
	sql_query_pre = SET NAMES UTF8
	sql_query_pre = SET SESSION query_cache_type=OFF
	sql_query_range = SELECT maxid-1,(SELECT MAX(tid) FROM bbs_forum_thread) FROM bbs_common_sphinxcounter WHERE indexid=1
}

# threads_minute
index pre_forum_thread_minute : pre_forum_thread
{
	source = pre_forum_thread_minute
	path = {$SERVER_APP}/index/db/pre_forum_thread/pre_forum_thread_minute
}

#posts
source pre_forum_post : pre_forum_thread
{
	type = mysql
	sql_query_pre =
	sql_query_pre = SET NAMES UTF8
	sql_query_pre = SET SESSION query_cache_type=OFF
	sql_query_pre = REPLACE INTO bbs_common_sphinxcounter SELECT 2, MAX(pid) FROM bbs_forum_post
	sql_query = SELECT p.pid AS id,p.tid,p.subject,p.message,t.digest,t.displayorder,t.authorid,t.lastpost,t.special \
			FROM bbs_forum_post AS p LEFT JOIN bbs_forum_thread AS t USING(tid) where p.pid >=$start and p.pid <=$end \
		AND p.first=1
	sql_query_range = SELECT (SELECT MIN(pid) FROM bbs_forum_post),maxid FROM bbs_common_sphinxcounter WHERE indexid=2
	sql_range_step = 5000
	sql_attr_uint = tid
	sql_attr_uint = digest
	sql_attr_uint= displayorder
	sql_attr_uint = authorid
	sql_attr_uint = special
	sql_attr_timestamp = lastpost
}

#posts
index pre_forum_post
{
	source			= pre_forum_post
	path			= {$SERVER_APP}/index/db/pre_forum_thread/pre_forum_post

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

#pre_forum_post_minute
source pre_forum_post_minute : pre_forum_post
{
	sql_query_pre = SET NAMES UTF8
	sql_query_pre = SET SESSION query_cache_type=OFF
	sql_query_range = SELECT maxid-1,(SELECT MAX(pid) FROM bbs_forum_post) FROM bbs_common_sphinxcounter WHERE indexid=2
}

#pre_forum_post_minute
index pre_forum_post_minute : pre_forum_post
{
	source			= pre_forum_thread
	path			= {$SERVER_APP}/index/db/pre_forum_thread/pre_forum_post_minute
}

