Revision 7588,
664 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 | |
---|
[7588] | 1 | <?php |
---|
| 2 | require('init.php'); |
---|
| 3 | |
---|
| 4 | htmlHeader(); |
---|
| 5 | |
---|
| 6 | // create a client instance |
---|
| 7 | $client = new Solarium_Client($config); |
---|
| 8 | |
---|
| 9 | // get a select query instance |
---|
| 10 | $query = $client->createSelect(); |
---|
| 11 | $query->setFields(array('id')); |
---|
| 12 | |
---|
| 13 | // get a plugin instance and apply settings |
---|
| 14 | $prefetch = $client->getPlugin('prefetchiterator'); |
---|
| 15 | $prefetch->setPrefetch(2); //fetch 2 rows per query (for real world use this can be way higher) |
---|
| 16 | $prefetch->setQuery($query); |
---|
| 17 | |
---|
| 18 | // display the total number of documents found by solr |
---|
| 19 | echo 'NumFound: ' . count($prefetch); |
---|
| 20 | |
---|
| 21 | // show document IDs using the resultset iterator |
---|
| 22 | foreach ($prefetch as $document) { |
---|
| 23 | echo '<hr/>ID: '. $document->id; |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | htmlFooter(); |
---|
Note: See
TracBrowser
for help on using the repository browser.