【实战】sphinx的配置文件

#源定义
source src1
{
        type                    = mysql
        sql_host                = localhost
        sql_user                = root
        sql_pass                =password
        sql_db                  = test
        sql_sock                = /usr/local/mysql/mysql.sock
        sql_query_pre           = SET NAMES utf8
        sql_query_pre           = REPLACE INTO sph_counter SELECT 1, MAX(id) FROM documents
        sql_query               =                 SELECT id, group_id, UNIX_TIMESTAMP(date_added) AS date_added, title, content                 FROM documents where id<=(SELECT max_doc_id FROM sph_counter WHERE counter_id=1)
        sql_attr_uint           = group_id
        sql_attr_timestamp      = date_added
        sql_ranged_throttle     = 0
}

#######源
#tblpnr
source src2
{
        type                    = mysql
        sql_host                = localhost
        sql_user                = root
        sql_pass                =password
        sql_db                  = jinripnr
        sql_sock                = /usr/local/mysql/mysql.sock
        sql_query_pre           = SET NAMES utf8
				sql_query_pre         	= REPLACE INTO jinri.sph_counter SELECT 2, MAX(id),max(update_time) FROM tblpnr
        sql_query               =                 SELECT id,orderno,pnr,ordertime FROM tblpnr where 		update_time<=(SELECT last_time FROM jinri.sph_counter WHERE counter_id=2)
        #字符串属性设置、需要过滤、排序的时候用到
	#sql_attr_uint           =
        sql_attr_timestamp      = ordertime
	sql_attr_string		= orderno  #只检索orderno
	sql_field_string 	= pnr
	#sql_field_string 用于全文即保存索引,sql_attr_string只用于检索即不保存索引

	#分区查询设置
	#sql_query_range = SELECT MIN(id),MAX(id) FROM tblpnr
	#sql_range_step = 500000
	#sql_query = SELECT * FROM tblpnr WHERE id>=$start AND id<=$end
  sql_ranged_throttle     = 0  #无时间间隔,单位是秒
}

#tblticketno
source src3
{
        type                    = mysql
        sql_host                = localhost
        sql_user                = root
        sql_pass                =password
        sql_db                  = jinritickno
        sql_sock                = /usr/local/mysql/mysql.sock
        sql_query_pre           = SET NAMES utf8
				sql_query_pre         	= REPLACE INTO jinri.sph_counter SELECT 3, MAX(id), 				max(update_time) FROM tblticketno
        sql_query               =                 SELECT id,orderno, ticketno,ordertime                 FROM tblticketno where update_time<=(SELECT last_time FROM jinri.sph_counter 		WHERE counter_id=3)
        #字符串属性设置、需要过滤、排序的时候用到
	#sql_attr_uint           =
        sql_attr_timestamp      = ordertime
	sql_attr_string		= orderno  #只检索orderno
	sql_field_string	= ticketno
	#sql_field_string 用于全文即保存索引,sql_attr_string只用于检索即不保存索引
  #分区查询设置
	#sql_query_range = SELECT MIN(id),MAX(id) FROM tblticketno
	#sql_range_step = 1000000
	#sql_query = SELECT * FROM tblticketno WHERE id>=$start AND id<=$end
  sql_ranged_throttle     = 0
}

#tblpassengername
source src4
{
        type                    = mysql
        sql_host                = localhost
        sql_user                = root
        sql_pass                =password
        sql_db                  = jinripname
        sql_sock                = /usr/local/mysql/mysql.sock
        sql_query_pre           = SET NAMES utf8
	sql_query_pre         	= REPLACE INTO jinri.sph_counter SELECT 4, MAX(id), 				max(update_time) FROM tblpassengername
        sql_query               =                 SELECT id,orderno, passengername,ordertime                 FROM tblpassengername where update_time<=(SELECT last_time FROM jinri.sph_counter 		WHERE counter_id=4)
        #字符串属性设置、需要过滤、排序的时候用到
	#sql_attr_uint           =
        sql_attr_timestamp      = ordertime
	sql_attr_string		= orderno  #只检索orderno
	sql_field_string	= passengername
	#sql_field_string 用于全文即保存索引,sql_attr_string只用于检索即不保存索引
        sql_ranged_throttle     = 0
}

#tblorderno
source src5
{
        type                    = mysql
        sql_host                = localhost
        sql_user                = root
        sql_pass                =password
        sql_db                  = jinriorderno
        sql_sock                = /usr/local/mysql/mysql.sock
        sql_query_pre           = SET NAMES utf8
        sql_query_pre           = REPLACE INTO jinri.sph_counter SELECT 5, MAX(id),                                 max(update_time) FROM tblorderno
        sql_query               =                 SELECT id,orderno,ordertime                 FROM tblorderno where update_time<=(SELECT last_time FROM jinri.sph_counter                 WHERE counter_id=5)
        #字符串属性设置、需要过滤、排序的时候用到
        #sql_attr_uint           =
        sql_attr_timestamp      = ordertime
        sql_field_string        = orderno
        #sql_field_string 用于全文即保存索引,sql_attr_string只用于检索即不保存索引
        sql_ranged_throttle     = 0
}

#tblpnr
source src2throttled : src2
{
	sql_ranged_throttle	= 100
}

#tblticketno
source src3throttled : src3
{
	sql_ranged_throttle	= 100
}

#tblpassengername
source src4throttled : src4
{
	sql_ranged_throttle	= 100
}

#tblorderno
source src5throttled : src5
{
	sql_ranged_throttle	= 100
}

########增量源
#tblpnr
source src2_delta:src2
{
        sql_query_pre           = SET NAMES utf8
	sql_query_pre         	=
        sql_query               =                SELECT id,orderno, pnr,ordertime                FROM tblpnr where update_time>(SELECT last_time 	       FROM jinri.sph_counter WHERE counter_id=2)
}

#tblticketno
source src3_delta:src3
{
        sql_query_pre           = SET NAMES utf8
	sql_query_pre         	=
        sql_query               =                SELECT id,orderno, ticketno,ordertime                FROM tblticketno where update_time>(SELECT last_time  	       FROM jinri.sph_counter WHERE counter_id=3)
}

#tblpassengername
source src4_delta:src4
{
        sql_query_pre           = SET NAMES utf8
	sql_query_pre         	=
        sql_query               =                SELECT id,orderno,passengername,ordertime                FROM tblpassengername where update_time>(SELECT last_time  	       FROM jinri.sph_counter WHERE counter_id=4)
}

#tblorderno
source src5_delta:src5
{
        sql_query_pre           = SET NAMES utf8
        sql_query_pre           =
        sql_query               =                SELECT id,orderno,ordertime                FROM tblorderno where update_time>(SELECT last_time                 FROM jinri.sph_counter WHERE counter_id=5)
}

######索引
#tblpnr
index src2
{
        source                  = src2
        path                    = /usr/local/sphinx/var/data/src2
        docinfo                 = extern
        dict                    = keywords
        mlock                   = 0
        morphology              = none
        min_word_len            = 1
        html_strip              = 0
        min_prefix_len = 0 #最小前缀
        min_infix_len = 0 #最小中缀
        ngram_len = 1 # 对于非字母型数据的长度切割,支持中文需要设置为1
        ngram_chars = U+4E00..U+9FBF, U+3400..U+4DBF, U+20000..U+2A6DF, U+F900..U+FAFF,U+2F800..U+2FA1F, U+2E80..U+2EFF, U+2F00..U+2FDF, U+3100..U+312F, U+31A0..U+31BF,U+3040..U+309F, U+30A0..U+30FF, U+31F0..U+31FF, U+AC00..U+D7AF, U+1100..U+11FF,U+3130..U+318F, U+A000..U+A48F, U+A490..U+A4CF
}

#tblticketno
index src3
{
        source                  = src3
        path                    = /usr/local/sphinx/var/data/src3
        docinfo                 = extern
        dict                    = keywords
        mlock                   = 0
        morphology              = none
        min_word_len            = 1
        html_strip              = 0
        min_prefix_len = 0 #最小前缀
        min_infix_len = 0 #最小中缀
        ngram_len = 1 # 对于非字母型数据的长度切割,支持中文需要设置为1
        ngram_chars = U+4E00..U+9FBF, U+3400..U+4DBF, U+20000..U+2A6DF, U+F900..U+FAFF,U+2F800..U+2FA1F, U+2E80..U+2EFF, U+2F00..U+2FDF, U+3100..U+312F, U+31A0..U+31BF,U+3040..U+309F, U+30A0..U+30FF, U+31F0..U+31FF, U+AC00..U+D7AF, U+1100..U+11FF,U+3130..U+318F, U+A000..U+A48F, U+A490..U+A4CF
}

#tblpassengername
index src4
{
        source                  = src4
        path                    = /usr/local/sphinx/var/data/src4
        docinfo                 = extern
        dict                    = keywords
        mlock                   = 0
        morphology              = none
        min_word_len            = 1
        html_strip              = 0
        min_prefix_len = 0 #最小前缀
        min_infix_len = 0 #最小中缀
        ngram_len = 1 # 对于非字母型数据的长度切割,支持中文需要设置为1
        ngram_chars = U+3000..U+2FA1F,U+4E00..U+9FBF, U+3400..U+4DBF, U+20000..U+2A6DF, U+F900..U+FAFF,U+2F800..U+2FA1F, U+2E80..U+2EFF, U+2F00..U+2FDF, U+3100..U+312F, U+31A0..U+31BF,U+3040..U+309F, U+30A0..U+30FF, U+31F0..U+31FF, U+AC00..U+D7AF, U+1100..U+11FF,U+3130..U+318F, U+A000..U+A48F, U+A490..U+A4CF
}

#tblorderno
index src5
{
        source                  = src5
        path                    = /usr/local/sphinx/var/data/src5
        docinfo                 = extern
        dict                    = keywords
        mlock                   = 0
        morphology              = none
        min_word_len            = 1
        html_strip              = 0
        min_prefix_len = 0 #最小前缀
        min_infix_len = 1 #最小中缀,支持模糊查询
        ngram_len = 1 # 对于非字母型数据的长度切割,支持中文需要设置为1
        ngram_chars = U+3000..U+2FA1F,U+4E00..U+9FBF, U+3400..U+4DBF, U+20000..U+2A6DF, U+F900..U+FAFF,U+2F800..U+2FA1F, U+2E80..U+2EFF, U+2F00..U+2FDF, U+3100..U+312F, U+31A0..U+31BF,U+3040..U+309F, U+30A0..U+30FF, U+31F0..U+31FF, U+AC00..U+D7AF, U+1100..U+11FF,U+3130..U+318F, U+A000..U+A48F, U+A490..U+A4CF
}

######增量索引
#tblprn
index src2_delta
{
        source                  = src2_delta
        path                    = /usr/local/sphinx/var/data/src2_delta
        docinfo                 = extern
        dict                    = keywords
        mlock                   = 0
        morphology              = none
        min_word_len            = 1
        html_strip              = 0
        min_prefix_len = 0 #最小前缀
        min_infix_len = 0 #最小中缀
        ngram_len = 1 # 对于非字母型数据的长度切割,支持中文需要设置为1
        ngram_chars = U+4E00..U+9FBF, U+3400..U+4DBF, U+20000..U+2A6DF, U+F900..U+FAFF,U+2F800..U+2FA1F, U+2E80..U+2EFF, U+2F00..U+2FDF, U+3100..U+312F, U+31A0..U+31BF,U+3040..U+309F, U+30A0..U+30FF, U+31F0..U+31FF, U+AC00..U+D7AF, U+1100..U+11FF,U+3130..U+318F, U+A000..U+A48F, U+A490..U+A4CF
}

#tblticketno
index src3_delta
{
        source                  = src3_delta
        path                    = /usr/local/sphinx/var/data/src3_delta
        docinfo                 = extern
        dict                    = keywords
        mlock                   = 0
        morphology              = none
        min_word_len            = 1
        html_strip              = 0
        min_prefix_len = 0 #最小前缀
        min_infix_len = 0 #最小中缀
        ngram_len = 1 # 对于非字母型数据的长度切割,支持中文需要设置为1
        ngram_chars = U+4E00..U+9FBF, U+3400..U+4DBF, U+20000..U+2A6DF, U+F900..U+FAFF,U+2F800..U+2FA1F, U+2E80..U+2EFF, U+2F00..U+2FDF, U+3100..U+312F, U+31A0..U+31BF,U+3040..U+309F, U+30A0..U+30FF, U+31F0..U+31FF, U+AC00..U+D7AF, U+1100..U+11FF,U+3130..U+318F, U+A000..U+A48F, U+A490..U+A4CF
}

#tblpassengername

index src4_delta
{
        source                  = src4_delta
        path                    = /usr/local/sphinx/var/data/src4_delta
        docinfo                 = extern
        dict                    = keywords
        mlock                   = 0
        morphology              = none
        min_word_len            = 1
        html_strip              = 0
        min_prefix_len = 0 #最小前缀
        min_infix_len = 0 #最小中缀
        ngram_len = 1 # 对于非字母型数据的长度切割,支持中文需要设置为1
        ngram_chars = U+4E00..U+9FBF, U+3400..U+4DBF, U+20000..U+2A6DF, U+F900..U+FAFF,U+2F800..U+2FA1F, U+2E80..U+2EFF, U+2F00..U+2FDF, U+3100..U+312F, U+31A0..U+31BF,U+3040..U+309F, U+30A0..U+30FF, U+31F0..U+31FF, U+AC00..U+D7AF, U+1100..U+11FF,U+3130..U+318F, U+A000..U+A48F, U+A490..U+A4CF
}

#tblorderno
index src5_delta
{
        source                  = src5_delta
        path                    = /usr/local/sphinx/var/data/src5_delta
        docinfo                 = extern
        dict                    = keywords
        mlock                   = 0
        morphology              = none
        min_word_len            = 1
        html_strip              = 0
        min_prefix_len = 0 #最小前缀
        min_infix_len = 1 #最小中缀,支持模糊查询
        ngram_len = 1 # 对于非字母型数据的长度切割,支持中文需要设置为1
        ngram_chars = U+4E00..U+9FBF, U+3400..U+4DBF, U+20000..U+2A6DF, U+F900..U+FAFF,U+2F800..U+2FA1F, U+2E80..U+2EFF, U+2F00..U+2FDF, U+3100..U+312F, U+31A0..U+31BF,U+3040..U+309F, U+30A0..U+30FF, U+31F0..U+31FF, U+AC00..U+D7AF, U+1100..U+11FF,U+3130..U+318F, U+A000..U+A48F, U+A490..U+A4CF
}

#########inherited index :索引继承
#tblpnr
#index src2stemmed : src2
#{
#	path			= /usr/local/sphinx/var/data/src2stemmed
#	morphology		= stem_en
#}

#tblticketno
#index src3stemmed : src3
#{
#	path			= /usr/local/sphinx/var/data/src3stemmed
#	morphology		= stem_en
#}

#tblpassengername
#index src4stemmed : src4
#{
#	path			= /usr/local/sphinx/var/data/src4stemmed
#	morphology		= stem_en
#}

#########分布式搜索
#tblpnr
index dist2
{
        type                    = distributed
        local                   = src2
        local                   = src2_delta
}

#tblticketno
index dist3
{
        type                    = distributed
        local                   = src3
        local                   = src3_delta
}

#tblpassengername
index dist4
{
        type                    = distributed
        local                   = src4
        local                   = src4_delta
}

#orderno:intpu value include *,not support dist query
#index dist5
#{
#        type                    = distributed
#        local                   = src5
#        local                   = src5_delta
#}

index rt
{
        type                    = rt
        path                    = /usr/local/sphinx/var/data/rt
        rt_field                = title
        rt_field                = content
        rt_attr_uint            = gid
}

indexer
{
        mem_limit               = 1024M
}

searchd
{
#        listen                  = /var/run/searchd.sock
        listen                  = 127.0.0.1:9312:sphinx
        listen                  = 9306:mysql41
        listen                  = 192.168.0.128:9312:sphinx
        log                     = /usr/local/sphinx/var/log/searchd.log
        query_log               = /usr/local/sphinx/var/log/query.log
        read_timeout            = 5
        client_timeout          = 300
        max_children            = 30
        persistent_connections_limit    = 30
        pid_file                = /usr/local/sphinx/var/log/searchd.pid
        seamless_rotate         = 1 ### 是否支持无缝切换,做增量索引时通常需要
        preopen_indexes         = 1
        unlink_old              = 1
        mva_updates_pool        = 1M
        max_packet_size         = 8M
        max_filters             = 256
        max_filter_values       = 4096
        max_batch_queries       = 32
        dist_threads            = 2

}
common
{
}

时间: 2024-11-05 23:10:53

【实战】sphinx的配置文件的相关文章

LNMP架构应用实战——Nginx服务配置文件介绍

LNMP架构应用实战--Nginx服务配置文件介绍 nginx的配置文件比较简单,但功能相当强大,可以自由灵活的进行相关配置,因此,还是了解下其配置文件的一此信息 1.Nginx服务目录结构介绍 安装完成后,在安装路径下就会有Nginx目录信息 [[email protected] application]# tree nginx nginx +-- client_body_temp +-- conf          #nginx服务配置文件目录 |   +-- fastcgi.conf  

Java实战之01Struts2-02配置文件

三.Struts2的配置文件 1.加载时机: 当应用被tomcat加载的时候,struts2的配置文件就已经被加载过了. 2.加载顺序 顺序 配置文件名 所在位置 说明 1 default.properties struts2-core-2.3.15.3.jar\org\apache\struts2 不能修改 2 struts-default.xml struts2-core-2.3.15.3.jar 不能修改 3 strtuts-plugin.xml 在struts2提供的插件jar包中 不能

sphinx 配置文件全解析

source:数据源,数据是从什么地方来的. index:索引,当有数据源之后,从数据源处构建索引.索引实际上就是相当于一个字典检索.有了整本字典内容以后,才会有字典检索. searchd:提供搜索查询服务.它一般是以deamon的形式运行在后台的. indexer:构建索引的服务.当要重新构建索引的时候,就是调用indexer这个命令. attr:属性,属性是存在索引中的,它不进行全文索引,但是可以用于过滤和排序. sphinx的配置文件过于冗长,我们把sphinx默认的配置文件中的注释部分去

sphinx配置文件详解

sphinx的配置文件是在配置的时候最容易出错的了: 我们先要明白几个概念: source:数据源,数据是从什么地方来的. index:索引,当有数据源之后,从数据源处构建索引.索引实际上就是相当于一个字典检索.有了整本字典内容以后,才会有字典检索. searchd:提供搜索查询服务.它一般是以deamon的形式运行在后台的. indexer:构建索引的服务.当要重新构建索引的时候,就是调用indexer这个命令. attr:属性,属性是存在索引中的,它不进行全文索引,但是可以用于过滤和排序.

[深入浅出Sphinx]Sphinx配置文件解析

上文介绍了Sphinx的工作原理,关于如何安装的文章在网上有很多,笔者就不再复述了,现在继续讲解Sphinx的配置文件,让Sphinx工作起来. 数据源配置 先来看一份数据源的配置文件示例: 1 source test 2 { 3 type = mysql 4 5 sql_host = 127.0.0.1 6 sql_user = root 7 sql_pass = root 8 sql_db = test 9 sql_port = 3306 # optional, default is 330

mac 下 sphinx + mysql + php 实现全文搜索(xampp)

原理: 使用sphinx 中的indexer 生成索引数据 service/web 端 利用searched 调用索引数据 步骤: 下载 sphinx: 下载地址:http://sphinxsearch.com/downloads/release/  这个可以根据自己电脑的系统来下载相应的安装包. ps:我是mac,所以 我下载了mac安装包,按照文档上的安装 发现不行,后来 我下载了第一个 即 Source tarball (tar.gz), 才安装成功的. 安装sphinx 参考地址:htt

SaltStack远程控制、配置管理与实战介绍

说明:      本文档仅写了一些基础的SaltStack操作命令,但这些命令也是工作中经常会用到的,像grains.pillar.jinja2功能更强大,但如果不是大批量升级改造的话一般不需用到.更高级的操作请参阅书籍. 1.salt常用命令 salt-key –L 或 salt-key:列出各minion的授权状态 salt 'minion-25.180' sys.doc test.echo: sys.doc用来获取模块的用处和示例用法 salt 'minion-25.180' test.p

sphinx实时更新

1 创建一个表[保存已经创建好的商品的最大ID]->能够根据这个ID找出哪些商品还没创建索引 每次创建好索引之后把最大的ID存进去,定期取出新的商品创建索引,创建完新的索引之后再把最大的ID更新到这个表 /************sphinx表***********/ drop table if exists p40_sphinx_id; create table p40__sphinx_id ( id mediumint unsigned not null default '0' commen

Sphinx速成指南

目录 1. Sphinx简介 1.1. 什么是全文检索 1.2. 介绍 1.3. Sphinx的特性 2. Sphinx安装(For MySQL) 2.1. Windows下安装 2.2. Linux下安装 3. 实例说明 4. Sphinx配置 5. 运行Sphinx 6. 搜索(翻译) 6.1. 匹配模式 6.2. 布尔查询语法(Boolean query syntax) 6.3. 扩展查询语法(Extended query syntax) 6.4. 权重(匹配度,Weight) 7. 如何