简体   繁体   English

如何在Sphinx中的一个索引中使用多个源?

[英]How do I use multiple sources in one index in Sphinx?

The Sphinx config file hints to it supporting multiple sources for one index, how do I actually specify it? Sphinx配置文件提示它支持一个索引的多个源,我该如何实际指定它?

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. 这两个来源是iwa_events和iwa_publications。 Both have unique id columns, and both sources work when indexed individually. 两者都有唯一的id列,两个源在单独编制索引时都有效。

If you want to search multiple indexes at once you have to specify them in your PHP code, not in the configuration file. 如果要一次搜索多个索引,则必须在PHP代码中指定它们,而不是在配置文件中指定它们。

Just seperate the indexes in your Query method (see documentation ): 只需在 Query方法中单独索引(请参阅 文档 ):

 
 
 
  
  $cl->Query ( "test query", "index1 index2" );
 
  

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. 请编辑您的问题,告诉我们您的实际问题是什么。

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: 看起来确实可以在一个索引中使用多个源,但前提是它们在模式方面是相同的,如文档中的这一行所示:

"source schemas must be the same in order to be stored within the same index." “源模式必须相同才能存储在同一索引中。”

Thanks very much for the help, Jan. It was my bad for the misunderstanding. 非常感谢你的帮助,Jan。这是我对误解的不利。 :D :d

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 只需在所有查询中给出相同名称的字段: sql_query = select id, catname as one, country as two, currency as three, language as four from catalog

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM