sphinx coreseek 初探_PHP教程

來源:互聯網
上載者:User
遇到了一些問題也都在上面的網站中找到了答案

下面是我的索引設定檔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/ #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
}

寫好索引檔案後需要建立索引,然後再建立進程就可以使用php的api了。

建立索引的命令:

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

/usr/local/coreseek/bin/indexer -c 索引設定檔地址 索引名字


如果需要重建立立索引則要在上面語句的最後加上 --rotate 參數

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

使用命令搜尋:

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


/usr/local/coreseek/bin/indexer -c 索引設定檔地址 要搜尋的關鍵字

啟動服務進程:

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


我測試的時候只能建立一個服務想建立另一個服務的時候需要將上一個服務關掉才行

例如我現在已經開啟了一個服務服務 是csft.conf 的,那麼我用

ps -ef | grep core

可以看到結果中有

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


這個一行,這時就需要先關掉csft.conf才行

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


這是才可以重建立立mysql.conf 的服務


http://www.bkjia.com/PHPjc/477313.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/477313.htmlTechArticle遇到了一些問題也都在上面的網站中找到了答案 下面是我的索引設定檔mysql.conf的內容 [php] source mysql { type = mysql sql_host = localhost sql_user...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.