如何在 Sphinx 的一个索引中使用多个源?
Sphinx 配置文件暗示它支持一个索引的多个源,我实际上如何指定它?
这是配置文件中的片段:
# document source(s) to index
# multi-value, mandatory
# document IDs must be globally unique across all sources
source = src1
我尝试将其设置为以下格式:
source = src1, src2
source = [src1, src2]
并且我还尝试使用源变量两次,例如:
source = src1
source = src2
我怀疑我只是个傻瓜,因为我不确定配置文件中使用的语法。有什么想法吗?
使用第二个代码片段时出现以下错误:
ERROR: index 'iwa': fulltext fields count mismatch (me=iwa_publications, in=iwa_events, myfields=3, infields=8).
两个源是 iwa_events 和 iwa_publications。两者都有唯一的 id 列,并且两个源在单独索引时都可以工作。
The Sphinx config file hints to it supporting multiple sources for one index, how do I actually specify it?
Here's the snippet from the config file:
# document source(s) to index
# multi-value, mandatory
# document IDs must be globally unique across all sources
source = src1
I've tried setting it in the following formats:
source = src1, src2
source = [src1, src2]
and I've also tried using the source variable twice, eg:
source = src1
source = src2
I suspect that I'm just being a dunce, as I'm not sure of the syntax to use in the config file. Any ideas?
Using the second code snippet I get the following error:
ERROR: index 'iwa': fulltext fields count mismatch (me=iwa_publications, in=iwa_events, myfields=3, infields=8).
The two sources are iwa_events and iwa_publications. Both have unique id columns, and both sources work when indexed individually.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您想一次搜索多个索引,则必须在 PHP 代码中指定它们,而不是在配置文件中。只需在
Query
方法中分隔索引即可(请参阅< a href="http://www.sphinxsearch.com/docs/current.html#api-funcgroup-querying" rel="nofollow noreferrer">文档):根据文档 你可以。
您的第二个代码片段是列出多个源的正确格式。请编辑您的问题以告诉我们您的实际问题是什么。
If you want to search multiple indexes at once you have to specify them in your PHP code, not in the configuration file.Just seperate the indexes in your
Query
method (see documentation):According to the documentation you can.
Your second code snippet is the correct format to list multiple sources. Please edit your question to tell us what your actual problem is.
发现问题:我误解了拥有多个来源的意义。看来多个源确实可以在一个索引中使用,但前提是它们在架构方面相同,如文档中的这一行所示:
非常感谢您的帮助,Jan。造成误解是我的错。 :D
Problem found: I misread the point of having multiple sources. It would appear that multiple sources can indeed be used in one index, but only if they're identical in terms of schema, as according to this line in the docs:
Thanks very much for the help, Jan. It was my bad for the misunderstanding. :D
是的。源模式必须相同;但你只需要相同数量的字段。
如果需要,您甚至可以使用同一字段两次。只需在所有查询中为字段提供相同的名称:
sql_query = select id, catname as one,country as 2,currency as 3, language as 4 from Catalog
yes. source schemas must be the same; but you only need same number of fields.
you can even use same field twice if needed. just give fields same name like this in all queries:
sql_query = select id, catname as one, country as two, currency as three, language as four from catalog