I use PHP library for sphinx. Wrote several sources in the sphinx.conf configuration (articles, news, notes).
After a successful search, I get an output array in PHP with the keys (IDs) of the rows found from each table (news, articles, messages).
Then I need to create a separate query for these obtained ID for each of the tables? To display the result to the user?
But if the output array will contain more than 1000 different identifiers? Will it be 1000 queries to the database? Many thanks for any comment or explanation!
One of the sources is described as follows:
source users : lsParentSource { sql_query_range = SELECT MIN(idDetailToUsers), MAX(idDetailToUsers) FROM detailtousers sql_range_step = 128 sql_query = SELECT idDetailToUsers as id, 9 as type, UsersTypeAccount, idDetailToUsers, SpecializationName, DetailToUsersName, DetailToUsersPhoto, city, country FROM detailtousers join users ON users.idUsers = detailtousers.idDetailToUsers left join usersspecialization ON usersspecialization.UsersSpecializationIdUser = detailtousers.idDetailToUsers left join specializationtousers ON specializationtousers.idSpecialization = usersspecialization.UsersSpecializationIdSpecialization WHERE idDetailToUsers >= $start AND idDetailToUsers <= $end GROUP BY idDetailToUsers sql_attr_uint = type sql_attr_uint = idDetailToUsers sql_attr_uint = UsersTypeAccount sql_field_string = SpecializationName sql_field_string = DetailToUsersName sql_field_string = DetailToUsersPhoto sql_attr_uint = city sql_attr_uint = country sql_query_info = SELECT idDetailToUsers, DetailToUsersName, UsersTypeAccount, SpecializationName, DetailToUsersPhoto, city, country \ FROM detailtousers WHERE idDetailToUsers = $id sql_ranged_throttle = 0 } If you specify by your example, then in the output array I get the name of the type: field type:
["fields"]=> array(4) { [0]=> string(4) "type" [1]=> string(18) "specializationname" [2]=> string(17) "detailtousersname" [3]=> string(18) "detailtousersphoto" } But without type (pointing to the table) Articles
I use the extension for PHP (PECL) Sphinx.
Code:
$ s = new SphinxClient; $ s-> setServer ("localhost", 9312);
$s->setMaxQueryTime(9000); $s->setMatchMode(SPH_MATCH_ANY); //$s->setFilter('type', array( 9, 10) ); $result = $s->query($_POST['search'], '*'); var_dump($result); 