wordpress coreseek全文搜索配置

全屏阅读
  • 基本信息
  • 作者:
  • 作者已发布:924篇文章
  • 发布时间:2021年03月28日 10:19:57
  • 所属分类:PHP+MySql
  • 阅读次数:1888次阅读
  • 标签:
	 # 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       = selectID,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       = selectID,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       = selectcomment_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       = selectcomment_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>';
顶一下
(0)
100%
订阅 回复
踩一下
(0)
100%
» 郑重声明:本文由mpxq168发布,所有内容仅代表个人观点。版权归恒富网mpxq168共有,欢迎转载, 但未经作者同意必须保留此段声明,并给出文章连接,否则保留追究法律责任的权利! 如果本文侵犯了您的权益,请留言。

目前有 0 条留言 其中:访客:0 条, 博主:0 条

给我留言

您必须 [ 登录 ] 才能发表留言!