コマンドライン検索(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'";