开发者

Sphinx Search Multiply Indexes & Sources

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 hav开发者_Python百科e 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!


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜