coreseek实战(一):windows下coreseek的安装与测试
網上關于 coreseek 在 windows 下安裝與使用的教程有很多,官方也有詳細的教程,這里我也只是按著官方提供的教程詳細的動手操作一遍,加深印象。官方頁面見:http://www.coreseek.cn/products-install/install_on_windows/
第一步:下載coreseek 3.2.14 for windows,并安裝
1、下載后解壓得到源程序目錄?coreseek-3.2.14-win32 ,文件夾重命名一下,簡單一些,命名為 coreseek;
2、將 coreseek 文件夾移動到 d:\www\ 下(根據你個人愛好,放哪都可以);
3、“開始”——>“運行”——>輸入cmd,打開命令行窗口——>執行 "d: 回車"——>執行 "cd www\coreseek\",進入到 coreseek目錄下;
4、執行 "set PATH=%CD%\bin;%PATH%"。設置path,目的是為了能夠調用bin目錄下的 cat.exe、iconv.exe 等;
5、將 searchd 安裝成為一個服務。執行 "bin\searchd --install --config d:/www/coreseek/etc/csft_mysql.conf",安裝成功后命令行窗口會提示" services searchd installed successfully"。注意兩點:
(1)、win7下命令行窗口需要以管理員身份運行,否則會出現”fatal openscmanager“錯誤而無法安裝
(2)、如果不把 searchd 安裝成為服務,那每次使用 coreseek 全文搜索,都得在命令行窗口打開 searchd 服務且不可關閉或停止(命令行窗口不需要開啟,使用api接口時需要)
-----第5點2013.2.7號修正,以上為錯誤的------
首先,需要配置好 index索引后,才可以安裝成為一個服務,所以,這點放在這是錯誤的;
其次,是補充一點,無法正常安裝,或安裝后啟動該服務時出現1067錯誤,很有可能是路徑問題:一是需要注意數據源配置文件里全部使用絕對路徑;二是上面的 install命令,也需要使用絕對路徑,而且路徑用 '/' ,不能是 '\'。
第二步:mysql數據源的配置與創建索引文件
1、配置 mysql 數據源及測試(在 coreseek\etc\csft_mysql.conf 文件)
說明:這里我沒有使用 coreseek 自帶的document.sql,而是使用了 我自己本身已有的一個數據庫數據,關于 csft_mysql.conf 配置文件中的各個配置項,我們在后面的文章中會做測試與學習,具體參考官方 coreseek 3.2 / sphinx 0.9.9 中文手冊。
#MySQL數據源配置,詳情請查看:http://www.coreseek.cn/products-install/mysql/ #請先將var/test/documents.sql導入數據庫,并配置好以下的MySQL用戶密碼數據庫#源定義 source weibo {type = mysqlsql_host = localhostsql_user = rootsql_pass = 123456sql_db = weibosql_port = 3306sql_query_pre = SET NAMES utf8sql_query = SELECT id, title, content FROM weibo #sql_query第一列id需為整數#title、content作為字符串/文本字段,被全文索引sql_attr_uint = group_id #從SQL讀取到的值必須為整數sql_attr_timestamp = date_added #從SQL讀取到的值必須為整數,作為時間屬性sql_query_info_pre = SET NAMES utf8 #命令行查詢時,設置正確的字符集sql_query_info = SELECT * FROM documents WHERE id=$id #命令行查詢時,從數據庫讀取原始數據信息 }#index定義 index weibo {source = weibo #對應的source名稱path = var/data/mysql #請修改為實際使用的絕對路徑,例如:/usr/local/coreseek/var/...docinfo = externmlock = 0morphology = nonemin_word_len = 1html_strip = 0#中文分詞配置,詳情請查看:http://www.coreseek.cn/products-install/coreseek_mmseg/#charset_dictpath = /usr/local/mmseg3/etc/ #BSD、Linux環境下設置,/符號結尾charset_dictpath = d:/www/coreseek/etc/ #Windows環境下設置,/符號結尾,最好給出絕對路徑,例如:C:/usr/local/coreseek/etc/...charset_type = zh_cn.utf-8 }#全局index定義 indexer {mem_limit = 128M }#searchd服務定義 searchd {listen = 9312read_timeout = 5max_children = 30max_matches = 1000seamless_rotate = 0preopen_indexes = 0unlink_old = 1pid_file = var/log/searchd_mysql.pid #請修改為實際使用的絕對路徑,例如:/usr/local/coreseek/var/...log = var/log/searchd_mysql.log #請修改為實際使用的絕對路徑,例如:/usr/local/coreseek/var/...query_log = var/log/query_mysql.log #請修改為實際使用的絕對路徑,例如:/usr/local/coreseek/var/... }2、創建索引
在命令行窗口下執行 " bin\indexer -c etc\csft_mysql.conf weibo",即:創建名為weibo的數據源的索引。如果需要創建 csft_mysql.conf 配置文件中的所有索引,剛使用 --all 替代 weibo。
D:\www\coreseek>bin\indexer -c etc\csft_mysql.conf weibo Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)] Copyright (c) 2007-2011, Beijing Choice Software Technologies Inc (http://www.coreseekusing config file 'etc\csft_mysql.conf'... indexing index 'weibo'... collected 8 docs, 0.0 MB sorted 0.0 Mhits, 100.0% done total 8 docs, 1381 bytes total 0.188 sec, 7319 bytes/sec, 42.40 docs/sec total 2 reads, 0.000 sec, 1.2 kb/call avg, 0.0 msec/call avg total 7 writes, 0.000 sec, 0.9 kb/call avg, 0.1 msec/call avg此時,在 coreseek\var\data 下發現,生成6個文件。
第三步:數據測試(命令行下不需要開啟 searchd 服務)
1、測試搜索中文。命令 為“ echo 搜索的詞 | iconv -f gbk -t utf-8 | search -c etc\csft_mysql.conf --stdin | iconv -f utf-8 -t gbk ”
D:\www\coreseek>echo 生意 | iconv -f gbk -t utf-8 | search -c etc\csft_mysql.con f --stdin | iconv -f utf-8 -t gbk Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)] Copyright (c) 2007-2011, Beijing Choice Software Technologies Inc (http://www.coreseek.com)using config file 'etc\csft_mysql.conf'... index 'weibo': query '生意 ': returned 1 matches of 1 total in 0.013 sec displaying matches: 1. document=2, weight=1, hit=22, dates=Thu Jan 01 08:33:32 1970id=2title=隊照排貨照炒 百度生意照做content=他還告訴記者,如果顧客在他們店購買iPhone5,iPhone4S的回收價格可 以再往上浮動300元左右,記者隨后咨詢了另外幾家手機店,發現回收價格基本在1500元至2 000元之間hit=22dates=2012-10-01words: 1. '生意': 1 documents, 1 hits2、搜索英文,出現亂碼是正常的。命令為” bin\search -c etc\csft_mysql.conf 搜索詞“
D:\www\coreseek>bin\search -c etc\csft_mysql.conf emall Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)] Copyright (c) 2007-2011, Beijing Choice Software Technologies Inc (http://www.coreseek.com)using config file 'etc\csft_mysql.conf'... index 'weibo': query 'emall ': returned 2 matches of 2 total in 0.013 secdisplaying matches: 1. document=8, weight=2, hit=0, dates=Thu Jan 01 08:33:32 1970id=8title=emall鐢靛瓙鍟嗗煄content=紲濊春emall鍟嗗煄鎴愮珛hit=0dates=2012-12-01 2. document=9, weight=2, hit=0, dates=Thu Jan 01 08:33:32 1970id=9title=emall鐢靛瓙鍟嗗煄content=紲濊春emall鍟嗗煄鎴愮珛hit=0dates=2012-12-01words: 1. 'emall': 2 documents, 4 hits補充說明(重點):測試中可能會出現以下兩個問題。
1、搜索中文時,出現 iconv 不是內部或外部命令。解決辦法:運行一下 "set PATH=%CD%\bin;%PATH%",即可解決;
2、搜索中文時,很多明明是詞語,但卻被拆分成單個字。解決辦法:需要使用同義詞\復合詞才能搞定,見官方教程mmseg 同義詞/復合分詞處理。
轉載于:https://www.cnblogs.com/phpway/archive/2013/02/06/2908097.html
總結
以上是生活随笔為你收集整理的coreseek实战(一):windows下coreseek的安装与测试的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 第一百三十九期:11月数据库排行:排名前
- 下一篇: c++ pat 乙级 -------10