Command line search (26019 documents / 26019 hits)
search.exe --config c:\sphinx\sphinx.conf keyword
OR
search.exe --config c:\sphinx\sphinx.conf keyword -e2
PHP API (Total: 1000 / Total found: 51038)
//sphinx command line and php api
mysql_connect("localhost", "username", "password");
mysql_select_db("database");
require_once('sphinxapi.php');
$cl = new SphinxClient;
$cl->setServer("127.0.0.1", 9312); // NOT "localhost" under Windows 7!
$cl->setMatchMode(SPH_MATCH_EXTENDED2);
$cl->SetLimits(0, 20);
$result = $cl->Query("keyword");
if ($result['total'] > 0)
{
echo 'Total: ' . $result['total'] . "<br />
";
echo 'Total Found: ' . $result['total_found'] . "<br />
";
echo '<table>';
echo '<tr><td>ID</td><td>Date</td><td>Title</td><td>Content</td></tr>';
foreach ($result['matches'] as $id => $otherStuff)
{
$row = mysql_fetch_array(mysql_query("select * from table where id = $id"));
extract($row);
echo "<tr><td>$id</td><td>$date</td><td>$title</td><td>$content</td></tr>";
}
echo '</table>';
}
else
{
echo 'No results found';
}
Match modes:
SPH_MATCH_ALL / SPH_MATCH_ANY / SPH_MATCH_PHRASE / SPH_MATCH_BOOLEAN / SPH_MATCH_EXTENDED / SPH_MATCH_EXTENDED2
PS: The command line result is the right one because I made the select directly from MySQL and i got it too.
$sql = "SELECT t1.field1, t1.field2, t1.field3, t2.field4
FROM t_table1 AS t1
LEFT JOIN t_table2 AS t2 ON t2.id = t1.t2_id WHERE t2.field4 LIKE 'keyword'";
Forget you found "search.exe". Ignore it. Really. Forget about it. Now. I'll wait.
Right now that over with, try being specific about what index you want to search (on the Query function call)
Also running once query for every row you get, is not good. You should only issue one SQL query for all results. The mysql IN() function makes it easy.
Example http://www.nearby.org.uk/sphinx/search-example5-withcomments.phps
More basic, but still functional example http://www.nearby.org.uk/sphinx/search-example2.phps
Sphinx is limited to returning only 1000 results.
There was some suggestions to raising that limit so check their page.Beware only that you can change that number in older sphinx relesase to whatever you wanted but it would return 1000 as max.
answer here:
http://sphinxsearch.com/docs/manual-2.0.5.html#conf-max-matches
unless you are planing to use the 26019 matches on the same page I suggest you use a pagination (if you're only displaying the results)