命令行搜索(26019 个文档 / 26019 个命中)
search.exe --config c:\sphinx\sphinx.conf keyword
或者
search.exe --config c:\sphinx\sphinx.conf keyword -e2
PHP API(总数:1000 / 找到总数: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 />\n";
echo 'Total Found: ' . $result['total_found'] . "<br />\n";
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';
}
匹配模式:
SPH_MATCH_ALL / SPH_MATCH_ANY / SPH_MATCH_PHRASE / SPH_MATCH_BOOLEAN / SPH_MATCH_EXTENDED / SPH_MATCH_EXTENDED2
PS:命令行结果是正确的,因为我直接从 MySQL 进行了选择,我也得到了它。
$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'";