Revision 7588,
1.1 KB
checked in by adir, 12 years ago
(diff) |
Ticket #000 - Adicionando a integracao de buscas com Solr na base a ser isnerida na comunidade
|
Rev | Line | |
---|
[7588] | 1 | |
---|
| 2 | <!----> |
---|
| 3 | <!--<html><head><title>Basic select</title></head><body>--> |
---|
| 4 | |
---|
| 5 | <?php |
---|
| 6 | require('../library/Solarium/Autoloader.php'); |
---|
| 7 | Solarium_Autoloader::register(); |
---|
| 8 | |
---|
| 9 | // create a client instance |
---|
| 10 | $client = new Solarium_Client(); |
---|
| 11 | |
---|
| 12 | // get a select query instance |
---|
| 13 | $query = $client->createSelect(); |
---|
| 14 | |
---|
| 15 | $query->setQuery("não"); |
---|
| 16 | |
---|
| 17 | // override the default row limit of 10 by setting rows to 30 |
---|
| 18 | $query->setRows(30); |
---|
| 19 | |
---|
| 20 | // this executes the query with default settings and returns the result |
---|
| 21 | $resultset = $client->select($query); |
---|
| 22 | |
---|
| 23 | // display the total number of documents found by solr |
---|
| 24 | echo 'NumFound: '.$resultset->getNumFound(); |
---|
| 25 | |
---|
| 26 | // show documents using the resultset iterator |
---|
| 27 | foreach ($resultset as $document) { |
---|
| 28 | |
---|
| 29 | echo '<hr/><table>'; |
---|
| 30 | |
---|
| 31 | // the documents are also iterable, to get all fields |
---|
| 32 | foreach($document AS $field => $value) |
---|
| 33 | { |
---|
| 34 | // this converts multivalue fields to a comma-separated string |
---|
| 35 | if(is_array($value)) $value = implode(', ', $value); |
---|
| 36 | |
---|
| 37 | echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>'; |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | echo '</table>'; |
---|
| 41 | } |
---|
| 42 | ?> |
---|
| 43 | <!--</body></html>--> |
---|
| 44 | |
---|
Note: See
TracBrowser
for help on using the repository browser.