I have two indexes for sphinx on my webserver for online movies website. 1st is for movies data, and 2d for actors data. Before i add 2nd index i used that code
public function sphinx_search($str) {
require_once('../tools/.sphinxapi.php');
$sphinx = new SphinxClient();
$sphinx->SetServer("127.0.0.1", 9312);
$sphinx->SetMatchMode(SPH_MATCH_ANY);
$sphinx->SetSortMode(SPH_SORT_RELEVANCE);
$sphinx->SetFieldWeights(['vis_title' => 100, 'title_en' => 5]);
$result = $sphinx->query($str, '*');
$ids = [];
if ($result && isset($result['matches'])) {
foreach ($result['matches'] as $k=>$v) {
$ids[] = $k;
}
}
return $ids;
}
Then i used these ids to search in mysql table movie
Is it possible to select specific index to search in? I mean select movies index or actors index in code $sphinx->query($str, '*')
p.s.: sorry about my english
The '*' in the second param is just which index(es) to search.
$sphinx->query($str, 'actors');
or
$sphinx->query($str, 'movies');
or
$sphinx->query($str, 'movies, actors');
or
public function sphinx_search($str, $indexes = '*') {
...
$sphinx->query($str, $indexes);
...