实现"mysql sphinx"的步骤
流程图
flowchart TD
A(创建索引文件) --> B(配置sphinx.conf)
B --> C(启动sphinx)
索引文件创建步骤
步骤 | 操作 |
---|---|
1 | 创建索引配置文件 |
2 | 创建数据源连接 |
3 | 配置字段 |
4 | 配置索引 |
创建索引配置文件
CREATE TABLE test1
(
id int unsigned not null primary key,
group_id int unsigned not null,
attr_multi multi,
attr_timestamp timestamp,
attr_bool bool,
attr_bigint bigint
);
创建数据源连接
source src1
{
type = mysql
sql_host = localhost
sql_user = root
sql_pass =
sql_db = test
sql_port = 3306
sql_query_pre = SET NAMES utf8
sql_query = \
SELECT id, group_id, attr_multi, attr_timestamp, attr_bool, attr_bigint \
FROM test1
}
配置字段
index test1
{
source = src1
path = /var/data/test1
docinfo = extern
charset_type = utf-8
charset_table = utf8
min_infix_len = 1
morphology = stem_ru
html_strip = 1
min_word_len = 1
min_prefix_len = 1
enable_star = 1
rt_field = title
rt_attr_uint = group_id
rt_attr_multi = attr_multi
rt_attr_timestamp = attr_timestamp
rt_attr_bool = attr_bool
rt_attr_bigint = attr_bigint
}
配置索引
indexer
{
mem_limit = 128M
}
配置sphinx.conf
searchd
{
listen = 9312
log = /var/log/sphinx_searchd.log
query_log = /var/log/sphinx_query.log
pid_file = /var/log/sphinx_searchd.pid
binlog_path = /var/data
}
indexer
{
mem_limit = 128M
}
searchd
{
listen = 9312
log = /var/log/sphinx_searchd.log
query_log = /var/log/sphinx_query.log
pid_file = /var/log/sphinx_searchd.pid
binlog_path = /var/data
}
启动sphinx
searchd --config sphinx.conf
现在你已经学会了如何实现"mysql sphinx",祝你学习顺利!
通过以上步骤,你已经掌握了如何实现"mysql sphinx"的过程。希望这篇文章对你有所帮助,祝你在开发的道路上越走越远!