gpt4 book ai didi

mysql - 使用 Sphinx 为 MySQL 表建立索引

转载 作者:行者123 更新时间:2023-11-29 11:56:19 25 4
gpt4 key购买 nike

我尝试用谷歌搜索这个,但我不确定我的术语是否错误,或者我对如何使用 Sphinx 有错误的想法。

我需要一些帮助来使用 sphinx 等工具从数据库创建和搜索表的索引。我运行的是 Ubuntu 14.04 LTS。

我的 sphinx 配置文件如下所示:

source db1
{
sql_host = localhost
sql_user = user1
sql_pass = pswd123
sql_db = db1
sql_port = 3306

type = mysql
sql_query = SELECT * FROM MetaData;
}

index myidx
{
source = mureinome
path = /var/lib/sphinxsearch/data/myidx
docinfo = extern

# Added after suggestion from Mihai
min_stemming_len = 1
min_word_len = 1
dict = keywords
}
indexer
{
mem_limit = 1000M
write_buffer = 50M
}
searchd
{
listen = 9312
listen = 9306:mysql41
pid_file = /var/run/sphinxsearch/searchd.pid
binlog_path = /var/lib/sphinxsearch/data
}

对我运行的表进行索引:

root@M4:/var/lib/sphinxsearch# indexer myidx --rotate
Sphinx 2.2.10-id64-release (2c212e0)
Copyright (c) 2001-2015, Andrew Aksyonoff
Copyright (c) 2008-2015, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file '/etc/sphinxsearch/sphinx.conf'...
indexing index 'myidx'...
WARNING: Attribute count is 0: switching to none docinfo
collected 1 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 1 docs, 459 bytes
total 0.005 sec, 80286 bytes/sec, 174.91 docs/sec
total 3 reads, 0.000 sec, 0.6 kb/call avg, 0.0 msec/call avg
total 9 writes, 0.000 sec, 0.6 kb/call avg, 0.0 msec/call avg
rotating indices: successfully sent SIGHUP to searchd (pid=2444).

但是当我尝试搜索索引时,我得到一个空结果:

SELECT * FROM myidx WHERE MATCH('FC') LIMIT 0,5;
Empty set (0.00 sec)

在 MySQL 中,表中的一列如下所示:

mysql> select SampleName from MetaData;
+-----------------+
| SampleName |
+-----------------+
| FCPG1048_S1S2S3 |
+-----------------+
1 row in set (0.00 sec)

我对表的索引是否错误,或者我对索引的搜索是否错误?任何帮助是极大的赞赏。

最佳答案

要启用部分词匹配,需要使用min_prefix_lenmin_infix_len

http://sphinxsearch.com/docs/current.html#conf-min-prefix-len

完成后,可以在查询中使用 *。或者使用 expand_keywords 来有效地自动执行此操作。

关于mysql - 使用 Sphinx 为 MySQL 表建立索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33145534/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com