例1 基本的な検索クエリ
<?php
try {
$swish = new Swish("index.swish-e");
$results = $swish->query("test OR text");
echo "Found ", $results->hits, " results\n";
while ($result = $results->nextResult()) {
var_dump($result);
break; //break after the first result
}
} catch (SwishException $e) {
echo "Error: ", $e->getMessage(), "\n";
}
?>
上の例の出力は、たとえば 以下のようになります。
Found 9 results object(SwishResult)#3 (8) { ["swishreccount"]=> int(1) ["swishrank"]=> int(1000) ["swishfilenum"]=> int(10) ["swishdbfile"]=> string(13) "index.swish-e" ["swishdocpath"]=> string(23) "README.SUBMITTING_PATCH" ["swishtitle"]=> NULL ["swishdocsize"]=> int(4557) ["swishlastmodified"]=> int(1072136752) }