Sphinx 搜索乘法索引和索引来源
我正在制作一个动态 CMS,因此 CMS 的每个实例都将在一个 MYSQL 数据库中拥有其表。到目前为止一切正常。
Envorioment:
8 个具有不同内容的不同站点。它们仅共享数据库名称,但都有不同的表 ($sitename_posts)
search enigne SPHINX
现在我陷入了困境:例如,当用户在站点 1 上进行搜索时,我想搜索所有表 $sitename_posts并返回最好的结果。
作为搜索引擎,我使用 sphinx。我已经尝试过使用两个来源和两个索引,但是当我搜索时:
$sphinx = new SphinxClient;
$sphinx->setServer($sphinx_host, $sphinx_port);
$sphinx->setMatchMode(SPH_MATCH_ANY);
$sphinx->setMaxQueryTime(10000);
$sphinx->SetSortMode(SPH_SORT_EXTENDED, '@relevance DESC');
$sphinx->SetLimits(0, 100, 300);
$result = $sphinx->query("Hello World", (index1 index2);
我没有得到任何结果。但是,如果我只建立一个索引并乘以来源,我会得到结果,但我无法确定我从哪个来源获取数据,所以我无法判断内容属于哪个网站。
还有一个问题是,当我搜索索引时,sphinx 是否有可能返回 ID 以及该 id 属于哪个索引?因为我需要确定哪个索引属于哪个结果。
感谢您的帮助!
Im making a dynamic CMS, so every instance of the CMS will have its on tables in one MYSQL DB. So far all is working.
The Envorioment:
8 different Sites with different content. they share only the DB name but all have differenttables ($sitename_posts)
search enigne SPHINX
Now im stuck at this: when for example user makes a search on site 1 i want search all tables $sitename_posts and return the best results.
As search engine i use sphinx. I have tried it with two sources and two indexes but when i search for example:
$sphinx = new SphinxClient;
$sphinx->setServer($sphinx_host, $sphinx_port);
$sphinx->setMatchMode(SPH_MATCH_ANY);
$sphinx->setMaxQueryTime(10000);
$sphinx->SetSortMode(SPH_SORT_EXTENDED, '@relevance DESC');
$sphinx->SetLimits(0, 100, 300);
$result = $sphinx->query("Hello World", (index1 index2);
I get no results. But if i build only one INDEX and multiply sources i get results, but i cant identify from which source i get the data, so i cant judge to which site the content belongs.
One more question is when i search the indexes, is it possible, that sphinx returns, the ID and to what index that id belongs? Cause i need to indentify which index belongs to which result.
Thanks for help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我正确理解了这个问题,那么值得您研究一下 Sphinx 的以下功能:
分布式索引 - 这将允许您为每个站点拥有一个索引,并且还拥有一个可以搜索的“虚拟”分布式索引当您想要获取数据时从应用程序中。
索引合并 - 这比分布式索引选项更持久,但索引器能够将多个索引合并为单个索引。我通常更喜欢使用分布式索引。
属性 - 这将允许您在每个索引中包含一个常量值(例如
siteId
),这将允许您识别搜索结果来自哪个索引。它还允许您在从单个分布式索引搜索时过滤结果。Sphinx 文档 - http://sphinxsearch.com/docs/2.0.1/
分布式索引解释- http://sphinxsearch.com/docs/2.0.1/distributed.html
配置分布式索引 - http://sphinxsearch.com/docs/2.0.1/confgroup-index.html
If I understand the question correctly I it's worth you looking into the following Sphinx features:
Distributed Indexes - This would allow you to have one index per site and also have a "virtual" distributed index which you could search from the application when you want to get data.
Index Merging - This is more permanent than the distributed index option but the indexer is able to merge multiple indexes into a single index. I would usually prefer to use distributed indexes.
Attributes - This would allow you to include a constant value in each of the indexes (e.g.
siteId
) which would allow you to identify which of the indexes the search result came from. It could also allow you to filter results when searching from the single distributed index.Sphinx docs - http://sphinxsearch.com/docs/2.0.1/
Distributed indexes explained - http://sphinxsearch.com/docs/2.0.1/distributed.html
Configuring distributed indexes - http://sphinxsearch.com/docs/2.0.1/confgroup-index.html