createSuggester();
$query->setQuery('ap ip v'); //multiple terms
$query->setDictionary('suggest');
$query->setOnlyMorePopular(true);
$query->setCount(10);
$query->setCollate(true);
// this executes the query and returns the result
$resultset = $client->suggester($query);
echo 'Query: '.$query->getQuery().'
';
// display results for each term
foreach ($resultset as $term => $termResult) {
echo '' . $term . '
';
echo 'NumFound: '.$termResult->getNumFound().'
';
echo 'StartOffset: '.$termResult->getStartOffset().'
';
echo 'EndOffset: '.$termResult->getEndOffset().'
';
echo 'Suggestions:
';
foreach($termResult as $result){
echo '- '.$result.'
';
}
echo '
';
}
// display collation
echo 'Collation: '.$resultset->getCollation();
htmlFooter();