參考文章:
用 php 構建自定義搜尋引擎
sphinx速成指南
測試環境
作業系統:windows xp
資料庫版本:mysql server version 5.0.45
一、安裝
詳細安裝過程參考
sphinx速成指南
二、測試sphinx自帶的demo。
1、匯入資料庫檔案example.sql。
該檔案在test資料庫新建立乙個documents,並插入基本的測試資料。
2、修改sphinx.conf.in檔案的配置引數,並儲存為sphinx.conf檔案。
主要修改以下幾個引數 第
一、連線資料庫的使用者名稱和密碼
sql_user = root
sql_pass = ***** #你自己的密碼 第
二、索引路徑
path = e:/web/sphinx/data/test1#改為自己的路徑
3、建立索引
bin/indexer.exe是建立索引的程式,具體引數可以在命令列下檢視幫助。
e:/web/sphinx>bin/indexer --config sphinx.conf test1
sphinx 0.9.8-release (r1371)
using config file 'sphinx.conf'...
indexing index 'test1'...
collected 4 docs, 0.0 mb
sorted 0.0 mhits, 100.0% done
total 4 docs, 193 bytes
total 0.127 sec, 1521.85 bytes/sec, 31.54 docs/sec
4、開啟查詢的守護程序
e:/web/sphinx>bin/searchd --config sphinx.conf
sphinx 0.9.8-release (r1371)
warning: forcing --console mode on windows
using config file 'sphinx.conf'...
warning: index 'test1stemmed': preload: failed to open @confdir@/data/test1stemm
ed.sph: no such file or directory; not serving
warning: index 'dist1': no such local index 'test1stemmed' - skipping local inde x
creating server socket on 0.0.0.0:3312
accepting connections
注意開啟3312埠,並修改相應的引數
5、查詢測試。
查詢了兩次,分別是ggart和another。結合資料庫檢視,結果是正確的。
e:/web/sphinx>bin/search -c sphinx.conf ggart
sphinx 0.9.8-release (r1371)
using config file 'sphinx.conf'...
index 'test1': query 'ggart ': returned 0 matches of 0 total in 0.000 sec
words:
1. 'ggart': 0 documents, 0 hits
index 'test1stemmed': search error: failed to open @confdir@/data/test1stemmed.s
ph: no such file or directory.
e:/web/sphinx>bin/search -c sphinx.conf another
sphinx 0.9.8-release (r1371)
using config file 'sphinx.conf'...
index 'test1': query 'another ': returned 1 matches of 1 total in 0.000 sec
displaying matches:
1. document=3, weight=2, group_id=2, date_added=tue aug 05 17:22:06 2008
id=3
group_id=2
group_id2=7
date_added=2008-08-05 17:22:06
title=another doc
content=this is another group
words:
1. 'another': 1 documents, 2 hits
index 'test1stemmed': search error: failed to open @confdir@/data/test1stemmed.s
ph: no such file or directory.
下一步測試sphinx的中文全文檢索和php程式的結合!
mysql全文檢索
全文索引在 mysql 中是乙個 fulltext 型別索引。fulltext 索引用於 myisam 表,可以在 create table 時或之後使用 alter table 或 create index 在 char varchar 或 text 列上建立。對於大的資料庫,將資料裝載到乙個沒有...
mysql全文檢索
mysql到版本3.23.23時,開始支援全文檢索,通過語句select from match against 來在整個表中檢索是否有匹配的,全文索引是乙個定義為fulltext的型別索引,應用在myisam表中。值得一提的是對於乙個大的資料庫來說,把資料裝載到乙個沒有fulltext索引的表中,然...
elasticSearch 全文檢索工具
index es裡的index相當於乙個資料庫。type 相當於資料庫裡的乙個表。id 唯一,相當於主鍵。node 節點是es例項,一台機器可以執行多個例項,但是同一臺機器上的例項在配置檔案中要確保http和tcp埠不同 下面有講 cluster 代表乙個集群,集群中有多個節點,其中有乙個會被選為主...