【问题标题】:Sphinx search by path of a wordSphinx 按单词路径搜索
【发布时间】:2019-03-09 14:49:49
【问题描述】:

我有一张简单的桌子

id: primary
name: varchar fulltext index

这是我的狮身人面像配置 https://justpaste.it/1okop

索引器对 docinfo 发出警告

Sphinx 2.2.11-id64-release (95ae9a6) 版权所有 (c) 2001-2016, Andrew Aksyonoff 版权所有 (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)

使用配置文件'/etc/sphinxsearch/sphinx.conf'...索引索引 'words'... 警告:属性计数为 0:切换到无 docinfo 收集了 10000 个文档,0.1 MB 排序 0.0 Mhits,完成 100.0% 总计 10000 文档,总共 79566 字节 0.065 秒,1210829 字节/秒,152179.20 docs/sec 共 3 次读取,0.000 秒,94.6 kb/call avg,0.0 msec/call avg 总共 9 次写入,0.000 秒,47.5 kb/调用平均值,0.0 毫秒/调用平均值

但是这里Sphinx: WARNING: Attribute count is 0: switching to none docinfo说没什么大不了的。

好的,开始服务并搜索部分单词:

SELECT *
FROM test_words
where match (name) AGAINST ('lema')
No rows.

Tha same as
SELECT *
FROM test_words
where match (name) AGAINST ('*lema*')

没有行。

同时有查询结果

SELECT *
FROM `test_words`
where position('lema' in name)>0

据我所知-Sphinx 不是按单词的一部分搜索的。 为什么以及如何解决?

而且 - 如果我取消注释

min_infix_len = 3 
infix_fields = name

我明白了

WARNING: index 'words': prefix_fields and infix_fields has no effect with dict=keywords, ignoring

还有一个 - 显示引擎; 没有显示 Sphinx 引擎,现在正常吗? mysql服务已重启。

所有的 sql 查询都是通过登录 localhost:3312 的管理员运行的

【问题讨论】:

    标签: sphinx


    【解决方案1】:

    Sphinx 中没有类似 position() 的函数或类似 'match(name) against' 的语法。根据您的配置,您的索引是“words”,而您的请求是针对“test_words”,这是您从中构建索引的源表。所以在我看来你不是连接到Sphinx,而是连接到mysql。如果您正在寻找 MySQL 和 Sphinx 之间更紧密的集成,请尝试使用 SphinxSE (http://sphinxsearch.com/docs/devel.html#sphinxse),然后它将显示在“SHOW ENGINES”中,或者如果您不想处理启用 SphinxSE 编译 MySQL,您可能想尝试Manticore Search(Sphinx 的一个分支),因为它集成了 FEDERATED 引擎 (https://docs.manticoresearch.com/2.6.4/html/federated_storage_engine.html),默认情况下编译在 mysql 中,您只需要正确启动它即可启用它。

    如果您想使用 Sphinx 传统方式,请确保您连接到它,而不是 MySQL。

    【讨论】:

    • 我想我连接到 Sphinx,请参阅屏幕截图 yadi.sk/i/UCqxbjrZiW2BMA,没有 Sphinx 引擎的原因可能是我错过了一些东西。我运行索引器,重新启动 sphinxsearch 和 mysql 服务,还有什么?..
    • Opps,我应该重新编译mysql吗?!
    • 您的屏幕截图表明您没有真正连接到 sphinx/searchd!首先,您在配置中有listen = 3312,这意味着 searchd 在该端口上的 SphinxnAPI 中列出 - 不是 SphinxQL(mysql 协议)!需要listen 9306:mysql41 或类似的。如果找到 mysql 套接字,您的 mysql 客户端可能会忽略指定的端口以绕过 TCP 连接。尝试使用 127.0.0.1 而不是 'localhost' - 因为 TCP 旁路通常被硬编码以显式使用 'localhost')
    • 是的,它工作,谢谢! 9306:mysql41 并登录到 127.0.0.1:9306。如果您写答案,我会将其标记为解决方案)
    【解决方案2】:

    在 sphinx 中它调用扩展语法,你应该通过@field 指定字段,试试这个:

    SELECT * FROM test_words
    WHERE match('@name lema')
    

    http://sphinxsearch.com/docs/current.html#extended-syntax

    【讨论】:

    • 虽然此代码 sn-p 可能会解决问题,但including an explanation 将帮助人们了解您的代码建议的原因。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-07
    相关资源
    最近更新 更多