I am try to getting started with Sphinx. I add some results to index, download sphinxapi.php
, and when I do this:
$cl = new SphinxClient();
$cl->SetServer( "localhost", 9312 );
// SPH_MATCH_ALL will match all words in the search term
$cl->SetMatchMode(SPH_MATCH_ALL);
$result = $cl->Query("test");
I getting this (row with id = 5
where title = test
):
array (size=1)
5 => // id of post in database
array (size=2)
'weight' => string '2' (length=1)
'attrs' =>
array (size=0)
empty
But why I didnt get row from database with id = 6
, where title
field equal to test1
?
And $cl->SetMatchMode(SPH_MATCH_ALL);
fire error:
DEPRECATED: Do not call this method or, even better, use SphinxQL instead of an API
I comment this line in code of api file:
trigger_error ( 'DEPRECATED: Do not call this method or, even better, use SphinxQL instead of an API', E_USER_DEPRECATED );
But I dont know if it fine. Can somebody help me to understand what I am doing wrong? Thanks!
To get 'substring' matches, you need to specifically enable them.
http://sphinxsearch.com/docs/current.html#conf-min-prefix-len
(or min_infix_len)
If you dont want to see the depreciated notice, then set error_reporting http://php.net/manual/en/function.error-reporting.php
(but even better is to rewrite the code to avoid calling the depreciated method)
warning setmatchmode
SetMatchMode are deprecated, you can still use it but it can be removed in next versions.
More info about it in:
extracted from sphinx forum (barryhunter):
Changing the 'match mode' actually did TWO things, it changed the matching >behaviour - by rewriting the query itself. AND changing the ranking mode.
By decoupling these concepts, I guess the idea is reduce confusion.
(for example, as soon as you choose a different matching mode, you can't >actully choose a ranking mode)
... the match modes made sence before the 'extended syntax' was fully developed, but now everything can be done directly via the extended syntax.
about search results
barryhunter answer is right
I suggest to read more about charset tables, morphology and stemming because i think are a better way to achieve success search than wilcard searches.