(PECL swish >= 0.1.0)
SwishSearch::setPhraseDelimiter — Set the phrase delimiter
$delimiter
)此函数是实验性的。此函数的表象,包括名称及其相关文档都可能在未来的 PHP 发布版本中未通知就被修改。使用本函数风险自担 。
delimiter
Phrase delimiter character. The default delimiter is double-quotes.
没有返回值。
Example #1 Basic SwishSearch::setPhraseDelimiter() example
<?php
try {
$swish = new Swish("index.swish-e");
$search = $swish->prepare();
$results = $search->execute('"every time"'); //looking for "every time"
echo "First query found: ", $results->hits, " hits\n";
$search->setPhraseDelimiter("'");
$results = $search->execute("'every time'"); //the same query, but using different delimiter
echo "Second query found: ", $results->hits, " hits\n";
$search->setPhraseDelimiter('"');
$results = $search->execute("'every time'"); //looking for "every" and "time"
echo "Third query found: ", $results->hits, " hits\n";
//let's look at parsed words
var_dump($results->getParsedWords("index.swish-e"));
} catch (SwishException $e) {
echo $e->getMessage(), "\n";
}
?>
以上例程的输出类似于:
First query found: 1 hits Second query found: 1 hits Third query found: 2 hits array(2) { [0]=> string(5) "every" [1]=> string(4) "time" }