Home  >  Article  >  Database  >  Coreseek:第一步配置文件

Coreseek:第一步配置文件

WBOY
WBOYOriginal
2016-06-07 15:56:571117browse

Windows操作系统下:mysql数据源配置:(对应coreseek-3.2.13-win32/etc/csft_mysql.conf) #源定义source mysql{type= mysql #表示使用mysql数据源sql_host= localhost #表示数据库服务器的链接地址sql_user= root #表示数据库的用户名sql_pass= 123456 #表

Windows操作系统下:mysql数据源配置:(对应coreseek-3.2.13-win32/etc/csft_mysql.conf)

#源定义
source mysql
{
	type				= mysql    #表示使用mysql数据源

	sql_host				= localhost    #表示数据库服务器的链接地址
	sql_user				= root          #表示数据库的用户名
	sql_pass				= 123456      #表示数据库的密码
	sql_db				= test          #表示数据库的名称
	sql_port				= 3306         #表示数据库的端口
	sql_query_pre			= SET NAMES utf8

	#从数据库之中读取数据的SQL语句设置
	sql_query				= SELECT id, group_id, UNIX_TIMESTAMP(date_added) AS date_added, title, content FROM documents
										#sql_query第一列id需为整数,且被系统使用,无需再设置sql_attr_uint

	#使用sql_attr设置的字段,只能作为属性,使用SphinxClient::SetFilter()进行过滤;未被设置的字段,自动作为全文检索的字段,使用SphinxClient::Query("搜索字符串")进行全文搜索;
	#title、content作为字符串/文本字段,被全文索引
	
	sql_attr_uint			= group_id				   #从SQL读取到的值必须为整数;sql_attr_uint表示该字段是数值属性
	sql_attr_timestamp		= date_added      #从SQL读取到的值必须为整数,作为时间属性;sql_attr_timestamp表示该字段是时间属性;可以不用该配置

    sql_query_info_pre      = SET NAMES utf8                                        #命令行查询时,设置正确的字符集,3.2.14开始支持
	sql_query_info			= SELECT * FROM documents WHERE id=$id  #命令行查询时,从数据库读取原始数据信息
}

#index定义
index mysql
{
    source            = mysql             #对应的source名称
    path            = var/data/mysql #索引存放的位置,路径为var/data
    docinfo            = extern
    mlock            = 0
    morphology        = none
    min_word_len        = 1
    html_strip                = 0
    #charset_dictpath = /usr/local/mmseg3/etc/    #BSD、Li}

 

需要注意的有:

1,必须有一个自增的字段id,当然你在数据库里写uid,nid其他的名字也行,ID属性,必须提供,在SQL语句中字段名称不限。对应SQL查询的第一个字段,系统自动使用,内部属性名为@id,不需要也不能在配置中设定。

2.sql_attr_float,sql_attr_string等是属性!属性是什么,属性是用来过滤的,比如你搜索时会选择某个时间段就会用到sql_attr_timestamp时间戳属性,搜索过滤某个人或者群组发的信息,就会用到 group_id和author_id这个属性,属性是用来过滤,不是用来索引的!所以,你如果在下面声明了属性,那么这个属性就不会建索引,即及你搜索这个id或者时间戳的时候会搜不到结果,所以你是要为这值建索引还是当做属性用还是要想一想

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn