Good time of day!
There is such a 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 } The entire table is indexed and stored in one large search index. When it comes to finding something in it, everything works OK
But today there was a task to perform a search by category. Categories are described in the type_id field and are of type int.
How in php through SphinxAPI to perform such a search?
Standard search looks like this.
$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'); I tried adding $sphinxClient->SetFilter('type_id','1'); to perform a search only where type_id = 1, but this did not help.
Actually: how can I search for a specific category? The option to find everything and to throw out unnecessary results from phpp is not considered (otherwise the search will be overwritten by the existing limit) how to do it “correctly” through the API, without putting each topic into a separate search index?
$array = array( "0" => 1, ); $sphinxClient->SetFilter('index_id',$array)$array = array( "0" => 1, ); $sphinxClient->SetFilter('index_id',$array)hasn’t changed anything at all, other garbage gets into the output - Stas Borzikh$sphinxClient->SetFilter('type_id', array(1))doesn't work either? - andreymal