Select 使用 php 搜索的索引
Select index to search in using php
我的在线电影网站的网络服务器上有两个 sphinx 索引。
1st 用于电影数据,2d 用于演员数据。
在我添加第二个索引之前,我使用了该代码
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;
}
然后我用这些id在mysqltablemovie
中搜索
是否可以select特定的索引进行搜索?
我的意思是 select 电影索引或代码中的演员索引 $sphinx->query($str, '*')
p.s.: 对不起我的英文
第二个参数中的'*'就是要搜索的索引。
$sphinx->query($str, 'actors');
或
$sphinx->query($str, 'movies');
或
$sphinx->query($str, 'movies, actors');
或
public function sphinx_search($str, $indexes = '*') {
...
$sphinx->query($str, $indexes);
...
我的在线电影网站的网络服务器上有两个 sphinx 索引。 1st 用于电影数据,2d 用于演员数据。 在我添加第二个索引之前,我使用了该代码
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;
}
然后我用这些id在mysqltablemovie
是否可以select特定的索引进行搜索? 我的意思是 select 电影索引或代码中的演员索引 $sphinx->query($str, '*')
p.s.: 对不起我的英文
第二个参数中的'*'就是要搜索的索引。
$sphinx->query($str, 'actors');
或
$sphinx->query($str, 'movies');
或
$sphinx->query($str, 'movies, actors');
或
public function sphinx_search($str, $indexes = '*') {
...
$sphinx->query($str, $indexes);
...