Sphinx works fine from linux console, but not with php api

My sphinx is working fine with linux console

This program (CLI search) is for testing and debugging purposes only;
it is NOT intended for production use.
[root@coinsaver sphinx]# search -i product -q iphone
Sphinx 2.1.8-id64-release (rel21-r4675)
Copyright (c) 2001-2014, Andrew Aksyonoff
Copyright (c) 2008-2014, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file '/etc/sphinx/sphinx.conf'...
index 'product': query 'iphone ': returned 88 matches of 88 total in 0.014 sec

displaying matches:
1. document=205267, weight=2773
2. document=470963, weight=2696
3. document=432191, weight=1696
4. document=125460, weight=1642
5. document=186938, weight=1642
6. document=199461, weight=1642
7. document=222081, weight=1642
8. document=249572, weight=1642
9. document=310231, weight=1642
10. document=395051, weight=1642
11. document=395052, weight=1642
12. document=430649, weight=1642
13. document=438066, weight=1642
14. document=468067, weight=1642
15. document=470947, weight=1642
16. document=470961, weight=1642
17. document=471161, weight=1642
18. document=482581, weight=1642
19. document=484640, weight=1642
20. document=490590, weight=1642

words:
1. 'iphon': 88 documents, 97 hits

BUT AFTER REWARDS, it does not work with PHP API

$sphinx = new SphinxClient();
// options....
$result = $sphinx->Query("$string*", '*');

returns false. It worked before I rebooted my server, it seems that Nginx and Sphinx no longer get along, I don’t even know where to start looking ....

result searchd --status

searchd status
--------------
uptime: 361
connections: 1
maxed_out: 0
command_search: 0
command_excerpt: 0
command_update: 0
command_keywords: 0
command_persist: 0
command_status: 1
command_flushattrs: 0
agent_connect: 0
agent_retry: 0
queries: 0
dist_queries: 0
query_wall: 0.000
query_cpu: OFF
dist_wall: 0.000
dist_local: 0.000
dist_wait: 0.000
query_reads: OFF
query_readkb: OFF
query_readtime: OFF
avg_query_wall: 0.000
avg_query_cpu: OFF
avg_dist_wall: 0.000
avg_dist_local: 0.000
avg_dist_wait: 0.000
avg_query_reads: OFF
avg_query_readkb: OFF
avg_query_readtime: OFF

In addition, after rebooting, there are no entries in the sphinx query log.

+4
source share
1 answer

Aha! After the reboot, my server decided to change the port for Sphinx from 9312 to 3312 , do not ask me how I did a simple reboot.

I ran this command to see open ports (CENTOS) $ netstat -tulpn | less

tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      4928/php-fpm
tcp        0      0 127.0.0.1:27017             0.0.0.0:*                   LISTEN      1166/mongod
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      4645/mysqld
tcp        0      0 0.0.0.0:3690                0.0.0.0:*                   LISTEN      1565/svnserve
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      3428/nginx
-----------------------------------------------------------------------------------------
tcp        0      0 127.0.0.1:3312              0.0.0.0:*                   LISTEN      3278/searchd
-----------------------------------------------------------------------------------------
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      529/sshd
tcp        0      0 :::22                       :::*                        LISTEN      529/sshd

So by changing this

$sphinx->SetServer('localhost', 9312);

to that

$sphinx->SetServer('localhost', 3312);

. , , , Linux.

+1

All Articles