Revision 7576,
998 bytes
checked in by adir, 11 years ago
(diff) |
Ticket #000 - Adicionando a integracao de buscas com Solr na base a ser isnerida na comunidade
|
Rev | Line | |
---|
[7576] | 1 | <?php |
---|
| 2 | |
---|
| 3 | require('init.php'); |
---|
| 4 | htmlHeader(); |
---|
| 5 | |
---|
| 6 | // create a client instance |
---|
| 7 | $client = new Solarium_Client($config); |
---|
| 8 | |
---|
| 9 | // get a suggester query instance |
---|
| 10 | $query = $client->createSuggester(); |
---|
| 11 | $query->setQuery('ap ip v'); //multiple terms |
---|
| 12 | $query->setDictionary('suggest'); |
---|
| 13 | $query->setOnlyMorePopular(true); |
---|
| 14 | $query->setCount(10); |
---|
| 15 | $query->setCollate(true); |
---|
| 16 | |
---|
| 17 | // this executes the query and returns the result |
---|
| 18 | $resultset = $client->suggester($query); |
---|
| 19 | |
---|
| 20 | echo '<b>Query:</b> '.$query->getQuery().'<hr/>'; |
---|
| 21 | |
---|
| 22 | // display results for each term |
---|
| 23 | foreach ($resultset as $term => $termResult) { |
---|
| 24 | echo '<h3>' . $term . '</h3>'; |
---|
| 25 | echo 'NumFound: '.$termResult->getNumFound().'<br/>'; |
---|
| 26 | echo 'StartOffset: '.$termResult->getStartOffset().'<br/>'; |
---|
| 27 | echo 'EndOffset: '.$termResult->getEndOffset().'<br/>'; |
---|
| 28 | echo 'Suggestions:<br/>'; |
---|
| 29 | foreach($termResult as $result){ |
---|
| 30 | echo '- '.$result.'<br/>'; |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | echo '<hr/>'; |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | // display collation |
---|
| 37 | echo 'Collation: '.$resultset->getCollation(); |
---|
| 38 | |
---|
| 39 | htmlFooter(); |
---|
Note: See
TracBrowser
for help on using the repository browser.