我使用PHP sphinx客户端(PECL):
$s = new SphinxClient; $s->setServer("localhost", 9312);
$s->setMaxQueryTime(9000);
$s->setMatchMode(SPH_MATCH_ANY);
$result = $s->query($_POST['search'], '*');
var_dump($result);
请求后我得到一个输出数组:
["fields"]=>
array(4) {
[0]=>
string(4) "type"
[1]=>
string(18) "specializationname"
[2]=>
string(17) "detailtousersname"
[3]=>
string(18) "detailtousersphoto"
}
在输出数组中,我试图获取表的名称,其中找到了数据(ID' s)。这个设置我在sphinx.conf中设置:
sql_query = SELECT idArticle as id, 'article' as type...
sql_field_string = type
如何获取表名'article'
?
来源 config 示例:
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
}
答案 0 :(得分:0)
结果数组应该包含一个&#39; attrs&#39;匹配数组中的数组(每个文档一个)。