博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
wordpress coreseek全文搜索配置
阅读量:5883 次
发布时间:2019-06-19

本文共 3943 字,大约阅读时间需要 13 分钟。

hot3.png

## 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 '
';        var_dump($result);        var_dump($err);        echo '
';

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

你可能感兴趣的文章
Oracle Database 11g SQL开发指南
查看>>
ACM一些小的注意事项 持续更新ing
查看>>
Go语言之单元测试
查看>>
贪心算法----解背包问题
查看>>
从循环条件的代码里,我能在面试中甄别程序员是否是高级
查看>>
方便查看 linux/kernel/sched.c
查看>>
C++三大特性之封装
查看>>
impinj sdk文档
查看>>
ubuntu系统下更新jdk版本
查看>>
LightSwitch OOB发布模式下 Title的处理
查看>>
基于HT for Web的Web SCADA工控移动应用
查看>>
基于 HTML5 的电力接线图 SCADA 应用
查看>>
浅谈Stingray中的定制与开发
查看>>
Asp.net MVC WebApi 中使用ELMAH
查看>>
Android开发笔记01
查看>>
折半查找法的温习
查看>>
YunTable开发日记(7)- BigTable的功能集(转载)
查看>>
点击开关按钮,通过改变类名切换按钮
查看>>
存储过程
查看>>
Asp.net 实现选择文件批量下载
查看>>