sphinx中文檢索安裝配置篇

來源:互聯網
上載者:User

Sphinx安裝及應用

一.安裝

參考http://www.coreseek.cn/docs/coreseek_4.1-sphinx_2.0.1-beta.html#supported-system

$ tar xzvf sphinx-2.0.1-beta.tar.gz
$ cd sphinx

1.首先安裝MMSeg:

$ cd mmseg

$ ./configure --prefix=/usr/local/mmseg

$ make

$ make install

$ cd ..

2.回合組態程式:

$ ./configure

configure程式有很多運行選項。完整的列表可以通過使用 --help 開關得到。最重要的如下:

--prefix, 定義將Coreseek安裝到何處;比如--prefix=/usr/local/sphinx(以下全部樣本都假定Coreseek安裝在這個位置)

--with-mysql, 當自動檢測失敗時,需要指出在那裡能找到MySQL 標頭檔和庫檔案;

--with-pgsql指出在那裡能找到PostgreSQL標頭檔和庫檔案.

--with-mmseg, 啟用基於MMSeg的中文分詞法,並指出在那裡能找到MMSeg標頭檔和庫檔案.

--with-python, 啟用Python資料來源支援. 需要預先安裝Python2.6.

3. 編譯原始碼產生二進位程式:

$ make

4. 安裝二進位程式到你設定的目錄下: (類Unix作業系統下預設為/usr/local/bin/ , 但是可以被 ./configure --prefix修改安裝目錄)

$ make install


. 配置

[zdh@gy03 etc]# cat /usr/local/sphinx/etc/movie.conf

#

# Minimal Sphinx configuration sample (clean, simple, functional)

#


source movie

{

type = mysql


sql_host = dbIP

sql_user = dbuser

sql_pass = dbpassword

sql_db = dbname

sql_port = 3306 # optional, default is 3306

sql_query_pre = SET NAMES utf8

sql_query = \

SELECT index_id,movie_id, movie_name,movie_name_alias, movie_name_pinyin, starin,starin_pinyin, director, director_pinyin, movie_type, show_time, region,IFNULL(ABS(TO_DAYS(show_time)-TO_DAYS(now())),187375) as near, weight \

FROM index_movie


sql_attr_uint = movie_id

sql_attr_uint = near

sql_attr_uint = weight

#sql_attr_timestamp = show_time

#sql_attr_str2ordinal = movie_name


sql_query_info = SELECT movie_id, movie_name,starin, director, movie_type, show_time, region FROM index_movie WHEREindex_id=$id

}



index movie

{

source = movie

path =/usr/local/sphinx/var/data/movie

charset_type = utf-8

charset_table = 0..9, A..Z->a..z, _, a..z,U+410..U+42F->U+430..U+44F, U+430..U+44F

#morphology = none

chinese_dictionary =/usr/local/sphinx/etc/xdict

#min_stemming_len = 1

#ngram_len = 1

#min_word_len = 2

ngram_chars = U+3000..U+2FA1F

}

indexer

{

mem_limit = 32M

}

searchd

{

listen = 9312

#listen = 9306:mysql41

log =/usr/local/sphinx/var/log/searchd.log

query_log =/usr/local/sphinx/var/log/query.log

read_timeout = 5

max_children = 30

pid_file =/usr/local/sphinx/var/log/searchd.pid

max_matches = 1000

seamless_rotate = 1

preopen_indexes = 1

unlink_old = 1

workers = threads # for RT to work

binlog_path = /usr/local/sphinx/var/data

}


. 啟動和建立索引

[zdh@gy03 etc]# searchd -c etc/movie.conf #啟動

[zdh@gy03 etc]# searchd -c etc/movie.conf--stop #關閉


crontab裡添加如下內容,使之定時更新

#sphinx indexer

00 06 * * * /usr/local/bin/indexer -c/usr/local/sphinx/etc/movie.conf movie --rotate



本文出自 “linuxblind開放空間” 部落格,轉載請與作者聯絡!

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.