|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-09-13 14:54 UTC] rich06 at gmail dot com
Description:
------------
I am trying to test Sphinx on my Mac development server (I am actually running PHP 5.3.3 however that version is absent from the selection list) and have installed the PECL extension to PHP. Sending a search query as follows:-
$s = new SphinxClient;
$s->setServer('localhost',6712);
$s->setMatchMode(SPH_MATCH_ANY);
$s->setMaxQueryTime(3);
$result = $s->query('foo');
Several results are obtained using the CLI search tool with the same search string;
The error returned by searchd is 'failed to send client protocol version'. This issue is discussed on the Sphinx site here -> http://www.sphinxsearch.com/forum/view.html?id=4919 and there is a fix described for the userland PHP API but I cannot see how to send the client protocol string using the PECL extension...
Reproduce code:
---------------
$s = new SphinxClient;
$s->setServer('localhost',6712);
$s->setMatchMode(SPH_MATCH_ANY);
$s->setMaxQueryTime(3);
$result = $s->query('foo');
Expected result:
----------------
Expect to get several results.
Actual result:
--------------
bool(false)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 13:00:02 2025 UTC |
OK I just tested on a Ubuntu 10.04 server with the same code as below: $s = new SphinxClient; $s->setServer('localhost',6712); $s->setMatchMode(SPH_MATCH_ANY); $s->setMaxQueryTime(3); $result = $s->query('foo','getProductsByName'); var_dump($result); var_dump($s); produces: bool(false) object(SphinxClient)#1 (2) { ["error"]=> string(38) "failed to send client protocol version" ["warning"]=> string(0) "" }Are you sure that your searchd is running on localhost:6712? If it's ok, please try to compile and run this code: ------------------------------------------ # test.c #include <stdio.h> #include <stdlib.h> #include "sphinxclient.h" int main () { sphinx_client *client; sphinx_result *res; sphinx_bool res_bool; const char *query, *index; query = "foo"; index = "getProductsByName"; client = sphinx_create(SPH_TRUE); if (!client) { printf("failed to create client\n"); exit(1); } res_bool = sphinx_set_server(client, "localhost", 6712); if (!res_bool) { printf("failed to set server\n"); exit(1); } res_bool = sphinx_set_match_mode(client, SPH_MATCH_ANY); if (!res_bool) { printf("failed to set match mode\n"); exit(1); } res_bool = sphinx_set_max_query_time(client, 3); if (!res_bool) { printf("failed to set max query time\n"); exit(1); } res = sphinx_query(client, query, index, NULL); if (!res) { printf("query failed: %s\n", sphinx_error(client)); exit(1); } printf("Query '%s' retrieved %d of %d matches.\n", query, res->total, res->total_found); return 0; } ------------------------------------------ $gcc -lsphinxclient -o test test.c $./test