Sphinx - fantasy0107/notes GitHub Wiki
全文搜索
步驟
spinx config 設定
source 和 index => 一對一
source TableName
{
type = 資料庫類型
sql_host = IP
sql_user = 資料庫帳號
sql_pass = 資料庫密碼
sql_db = 哪一個資料庫
sql_port = 3306 # default
sql_query_pre = sql query
sql_query = sql query
sql_attr_timestamp = time
sql_query_info = ...
sql_attr_uint = ... //會出現在 sphinx 結果中的column
}
index TableName
{
source = TableName # 使用哪一個來源(這邊就是用上面那一個 source)
path = sphinx 底下這一個 TableName 路徑
docinfo = ...
charset_type = utf-8
charset_table = ...
ngram_chars = ...
ngram_len = 1
}
語法
# 註解
\ 同一行
下 command 建立 index
/usr/bin/indexer --config /etc/sphinxsearch/sphinx.conf index user_item_memo --rotate
寫相關程式邏輯
撈回來的資料格式
0 => "Query '中等' retrieved 4 of 4 matches in 0.002 sec."
1 => "Query stats:"
2 => " '中' found 25102 times in 15693 documents"
3 => " '等' found 29999 times in 26119 documents"
4 => ""
5 => "Matches:"
6 => "1. doc_id=69173, weight=200518, catid=6, year=2018, date_added=2018-05-27 10:08:15"
7 => "2. doc_id=69792, weight=200518, catid=6, year=2018, date_added=2018-06-15 01:41:04"
8 => "3. doc_id=69910, weight=200518, catid=6, year=2018, date_added=2018-06-21 04:42:32"
9 => "4. doc_id=69974, weight=200522, catid=6, year=2018, date_added=2018-06-26 01:30:23"
其它
linux 編輯檔案
nano /aaa/sphinx.conf
nano 搜尋 - ^W search or find some text in nano
複製/上傳檔案
scp 上傳檔案
scp 從這裡 複製到這裡
scp [email protected]:/etc/s.conf . (將s.conf 複製到當前的路徑)