执行类别搜索Sphinx PHP



一天中的好时机!

有这样的config sphinx

    source txtcontent :  ru_config
{ 
  sql_query = SELECT `id` as `txt_id`, 1 as index_id, `type_id`,`content_type_id`, `title`, `annonce`, `content` FROM `TxtContent` WHERE `status` = 1 AND `content_type_id` != 14
  sql_attr_uint   = index_id
  sql_attr_uint   = type_id
}

整个表已索引,并存储在一个大型搜索索引中。当涉及到其中的内容时,所有人都可以正常工作

,但今天的任务是搜索类别字段中描述的类别并具有type_id type int int在使用phinxapi的PHP中,如何执行此类搜索?标准搜索看起来像这样。

$sphinxClient = new SphinxClient();
$sphinxClient->SetServer("127.0.0.1", 3312 );
$sphinxClient->SetLimits( 0, 700,700 );
$sphinxClient->SetSortMode(SPH_SORT_RELEVANCE);
$sphinxClient->SetArrayResult( true );
$result = $sphinxClient->Query( $this->query, 'txtcontent provider item');

我尝试添加

$ sphinxclient-> setFilter('type_id','1');

仅在type_id = 1的地方搜索,但没有帮助。

实际上如何搜索特定类别?不考虑将所有PHP中的所有内容丢弃的选项不考虑结果(否则,搜索将为饱和度限制)如何通过API"正确地"而不将每个主题放入单独的搜索索引中"正确"?

setFilter占值的 array 。它们需要是数字type_id是数字属性)

$sphinxClient->SetFilter('type_id',array(1));

sphinxapi class actully使用断言来检测无效的数据,我想您已经禁用了(否则会看到它们!)。

最新更新