0

I've recently installed sphinx for my MySQL database, and have configured the config file & I am getting correct results when running search.exe, but when I use the PHP API (along with its wrapper for CodeIgniter ). I am still 0 zero results. Now I am pretty sure that my php code is correct since it is basic (get the keys, run a mysql query, and the return the results). What reasons could cause such a problem? here is the searchd portion of the sphinx config file, do I need to modify anything? :

searchd
{
# listen            = 9312
listen          = 9306:mysql41
port            = 3312
log         = C:/sphinx/log/searchd.log
query_log       = C:/sphinx/log/query.log
read_timeout        = 5
max_children        = 30
pid_file        = C:/sphinx/log/searchd.pid
max_matches     = 1000
seamless_rotate     = 1
preopen_indexes     = 1
unlink_old      = 1
workers         = threads # for RT to work
binlog_path     = C:/sphinx/data


}

and here is my search.php sphinx query:

        $search_string=$this->input->post('q');
        $this->load->library('Sphinxclient');
        $this->sphinxclient->setMatchMode(SPH_MATCH_ANY);
        $this->sphinxclient->SetArrayResult(TRUE);
        $users_ids=$this->sphinxclient->Query('users_info',$search_string);

Now I am not sure how the API or sphinx finds the mysql directory and connects to it, but I am reading the sphinx documentation, and in the basic api functions section, it says that the function SetServer has default values of "localhost", and port "9312". Could this be the problem since in my config file I have a different port and I have commented out the 9312 listening?

Here is my definition of users_info source and index (although I doubt this is the problem since search.exe is able to get results).

source users_info
{
type                            = mysql

sql_host                        = localhost
sql_user                        = admin
sql_pass                        = admin
sql_db                          = users
sql_sock                        =  /var/run/mysqld/mysqld.sock
sql_port                        = 3306                  


sql_query                       = \
        SELECT id, fullname,username FROM users_info;



sql_query_info          = SELECT * FROM users WHERE id=$id
}

and index:

index users_info
{
source          = users_info
path            = C:/sphinx/data/users_info
docinfo         = extern
charset_type        = utf-8
}

Also, one more thing, in the API, I flipped the arguments in the Query function in the API, I have fixed that but that didn't fix the issue.

Any Ideas?

4

1 回答 1

1

它说函数 SetServer 的默认值为“localhost”和端口“9312”。这可能是问题,因为在我的配置文件中我有一个不同的端口并且我已经注释掉了 9312 监听?

那肯定是问题的根源。您需要服务器侦听客户端尝试连接的端口。它们必须相同。

就此而言,您甚至运行了 searchd 服务器守护程序吗?在 windows 下通常将其安装为服务。

(并检查防火墙是否阻止访问 searchd 正在侦听的端口)

于 2012-10-07T18:36:08.193 回答