A preliminary exploration of sphinx coreseek_PHP tutorial

WBOY
Release: 2016-07-14 10:11:31
Original
964 people have browsed it

I encountered some problems and found the answers on the above website

The following is the content of my index configuration file mysql.conf


[php]
source mysql 

    type                = mysql 
 
    sql_host                = localhost 
    sql_user                = root 
    sql_pass                = mfy 
    sql_db                = zlk 
    sql_port                = 3306 
    sql_query_pre            = SET NAMES utf8 
 
    sql_query                = SELECT id,pic_id,city,captionwriter,countryname,title,description,contenttype,generator,author,keyword,language,datecreatedline  FROM picture_info 
                                                              #sql_query第一列id需为整数 
                                                              #title、content作为字符串/文本字段,被全文索引 
   # sql_attr_uint            = id           #从SQL读取到的值必须为整数 
   sql_attr_uint            = pic_id           #从SQL读取到的值必须为整数 
   sql_attr_timestamp        = datecreatedline #从SQL读取到的值必须为整数,作为时间属性 
   # sql_attr_str2ordinal       = title 
 

 
#index定义 
index mysql 

    source            = mysql             #对应的source名称 
    path            = /usr/local/coreseek/var/data/mysql 
 
    docinfo            = extern 
    mlock            = 0 
    morphology        = none 
    min_word_len        = 1 
    min_infix_len =1 
    html_strip                = 0 
    charset_dictpath = /usr/local/mmseg3/etc/    #BSD、Linux环境下设置,/符号结尾 
    #charset_dictpath = etc/                        #Windows环境下设置,/符号结尾 
    charset_type        = zh_cn.utf-8 

#全局index定义 
indexer 

    mem_limit           = 2G 

 
 
searchd 

       listen                                   = 9312 
       max_matches                              = 10000 
       pid_file                                 = /usr/local/coreseek/var/log/searchd_mysql.pid 
       log                                      = /usr/local/coreseek/var/log/searchd_mysql.log 
       query_log                                = /usr/local/coreseek/var/log/query_mysql.log 

source mysql
{
    type                = mysql

    sql_host                = localhost
    sql_user                = root
    sql_pass                = mfy
    sql_db                = zlk
    sql_port                = 3306
    sql_query_pre            = SET NAMES utf8

    sql_query                = SELECT id,pic_id,city,captionwriter,countryname,title,description,contenttype,generator,author,keyword,language,datecreatedline  FROM picture_info
                                                              #sql_query第一列id需为整数
                                                              #title、content作为字符串/文本字段,被全文索引
   # sql_attr_uint            = id           #从SQL读取到的值必须为整数
   sql_attr_uint            = pic_id           #从SQL读取到的值必须为整数
   sql_attr_timestamp        = datecreatedline #从SQL读取到的值必须为整数,作为时间属性
   # sql_attr_str2ordinal       = title

}

#index定义
index mysql
{
    source            = mysql             #对应的source名称
    path            = /usr/local/coreseek/var/data/mysql

docinfo = extern
mlock = 0
Morphology = none
min_word_len = 1
Min_infix_len =1
html_strip = 0
charset_dictpath = /usr/local/mmseg3/etc/ #Set in BSD and Linux environments, ending with / symbol
#charset_dictpath = etc/ #charset_dictpath = etc/ #Set in Windows environment, ending with / symbol
charset_type = zh_cn.utf-8
}
#Global index definition
indexer
{
mem_limit = 2G
}


searchd
{
listen = 9312
max_matches = 10000
pid_file pid_file = /usr/local/coreseek/var/log/searchd_mysql.pid
log = /usr/local/coreseek/var/log/searchd_mysql.log
query_log = /usr/local/coreseek/var/log/query_mysql.log
}

After writing the index file, you need to create the index, and then create the process to use the PHP API.

Indexing command:

/usr/local/coreseek/bin/indexer -c etc/mysql.conf mysql

/usr/local/coreseek/bin/indexer -c Index configuration file address Index name


If you need to re-index, add the --rotate parameter at the end of the above statement

/usr/local/coreseek/bin/indexer -c etc/mysql.conf mysql --rotate

Search using command:

/usr/local/coreseek/bin/search -c etc/mysql.conf "Test"


/usr/local/coreseek/bin/indexer -c Index configuration file address Keywords to be searched

Start the service process:

/usr/local/coreseek/bin/searchd -c etc/mysql.conf


When I was testing, I could only create one service. When I wanted to create another service, I had to turn off the previous service

For example, I have now opened a service in csft.conf, then I use

ps -ef | grep core

You can see that there is

in the results

root 11730 1 0 14:33 pts/0 00:00:00 /usr/local/coreseek/bin/searchd -c etc/csft.conf


This line, then you need to close csft.conf first

/usr/local/coreseek/bin/searchd -c etc/csft.conf --stop


This is the only way to re-establish the mysql.conf service


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477313.htmlTechArticleI encountered some problems and found the answers on the above website. The following is my index configuration file mysql.conf Content [php] source mysql { type = mysql sql_host = localhost sql_user...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template