Sphinx是一个基于SQL的全文检索引擎,可以结合MySQL,PostgreSQL做全文搜索,它可以提供比数据库本身更专业的搜索…
安装sphinx
配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
| # 全局设置
source src1 {
type = mysql
sql_host = 192.x.x.x
sql_user = xxxxxx
sql_pass = xxxxxx
sql_db = search
sql_port = 3306
sql_query_pre = SET NAMES utf8
}
# 继承数据库设置
source product : src1 {
sql_query = SELECT `id`,`key` FROM sphinx_searchs
}
# 索引文件设置
index product {
source = product
path = /webroot/database/sphinx/product
docinfo = extern
dict = keywords
mlock = 0
morphology = none
min_word_len = 1
ngram_chars = U+3000..U+2FA1F
html_strip = 1
min_prefix_len = 0
min_infix_len = 1
ngram_len = 1
}
|
建立索引和启动
1
2
| indexer --config ./config.conf --all
searchd --config ./config.conf
|