wordpress coreseek全文搜索配置

#
# Minimal Sphinx configuration sample (clean, simple, functional)
#
source wp_posts
{
	# data source type. mandatory, no default value
	# known types are mysql, pgsql, mssql, xmlpipe, xmlpipe2, odbc
	type			= mysql
	#####################################################################
	## SQL settings (for 'mysql' and 'pgsql' types)
	#####################################################################

	# some straightforward parameters for SQL source types
	sql_host		= localhost
	sql_user		= root
	sql_pass		= root
	sql_db			= test
	sql_port		= 3306	# optional, default is 3306

	#待索引数据获取前查询
    sql_query_pre		= SET NAMES utf8
	sql_query_pre		= SET SESSION query_cache_type=OFF


    sql_query       = select ID,post_content,post_title,post_name,guid,UNIX_TIMESTAMP(post_date) post_date \
                        from wp_posts
                        
	#sql_field_string		= post_title
    #sql_field_string     = post_content
    sql_attr_timestamp = post_date
    #sql_query_info      = select * from wp_posts where ID=$id
}
index wp_posts
{
    source          = wp_posts
	path			= /home/coreseek/data/59n_posts
	docinfo			= extern
    charset_dictpath = /usr/local/mmseg3/etc/
	charset_type		= zh_cn.utf-8
}

########增量索引,进行实时更新

source wp_posts_rt:wp_posts
{
    sql_query       = select ID,post_content,post_title,post_name,guid,UNIX_TIMESTAMP(post_date) \
                        post_date \
                        from wp_posts where UNIX_TIMESTAMP(post_modified) > UNIX_TIMESTAMP() - 300
}
index wp_posts_rt
{
    source          = wp_posts_rt
	path			= /home/coreseek/data/59n_posts_rt
	docinfo			= extern
    charset_dictpath = /usr/local/mmseg3/etc/
	charset_type		= zh_cn.utf-8
}


source wp_comment
{
    type			= mysql
    sql_host		= localhost
	sql_user		= root
	sql_pass		= root
	sql_db			= test
	sql_port		= 3306	# optional, default is 3306
    #待索引数据获取前查询
    sql_query_pre		= SET NAMES utf8
	sql_query_pre		= SET SESSION query_cache_type=OFF


    sql_query       = select comment_ID,comment_post_ID,comment_author,comment_content,UNIX_TIMESTAMP(comment_date) comment_date from wp_comments
                        
    sql_attr_uint       = comment_post_ID
	#sql_field_string		= comment_author
    #sql_field_string     = comment_content

    sql_attr_timestamp = comment_date
    #sql_query_info      = select * from wp_comments where comment_ID=$id
}



index wp_comment
{
    source          = wp_comment
	path			= /home/coreseek/data/59n_comment
	docinfo			= extern
    charset_dictpath = /usr/local/mmseg3/etc/
	charset_type		= zh_cn.utf-8
}

########增量索引,进行实时更新

source wp_comment_rt:wp_comment
{
    sql_query       = select comment_ID,comment_post_ID,comment_author,comment_content,UNIX_TIMESTAMP(comment_date) comment_date from wp_comments \
                        where UNIX_TIMESTAMP(comment_date) > UNIX_TIMESTAMP() - 300
}
index wp_comment_rt
{
    source          = wp_comment_rt
	path			= /home/coreseek/data/59n_comment_rt
	docinfo			= extern
    charset_dictpath = /usr/local/mmseg3/etc/
	charset_type		= zh_cn.utf-8
}

indexer
{
	mem_limit		= 256M
}


searchd
{
	listen			= 9312
	listen			= 9306:mysql41
	log			= /usr/local/coreseek/var/log/searchd.log
	query_log		= /usr/local/coreseek/var/log/query.log
	read_timeout		= 5
	max_children		= 10
	pid_file		= /usr/local/coreseek/var/log/searchd.pid
	max_matches		= 1000
	seamless_rotate		= 1
	preopen_indexes		= 1
	unlink_old		= 1
	workers			= threads # for RT to work
}

进行首次索引 

./bin/indexer --all

使用crontab -e进行增量索引进行实时更新

*/4 * * * * /usr/local/coreseek/bin/indexer --rotate wp_posts_rt wp_comment_rt

*/4 * * * * /usr/local/coreseek/bin/indexer --rotate --merge wp_posts wp_posts_rt

*/4 * * * * /usr/local/coreseek/bin/indexer --rotate --merge wp_comment wp_comment_rt

在PHP中使用sphinx扩展进行搜索.

$sp = new SphinxClient();
        $sp->setMatchMode(SPH_MATCH_ANY);
        $result = $sp->query($name);
        //$err 错误
        $err = $sp->GetLastError();
        echo '<pre>';
        var_dump($result);
        var_dump($err);
        echo '</pre>';

转载于:https://my.oschina.net/qq277049/blog/81456

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值