Revision 7576,
807 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 select query instance |
---|
| 10 | $query = $client->createSelect(); |
---|
| 11 | |
---|
| 12 | // create a filterquery |
---|
| 13 | $query->createFilterQuery('maxprice')->setQuery('price:[1 TO 300]'); |
---|
| 14 | |
---|
| 15 | // this executes the query and returns the result |
---|
| 16 | $resultset = $client->select($query); |
---|
| 17 | |
---|
| 18 | // display the total number of documents found by solr |
---|
| 19 | echo 'NumFound: '.$resultset->getNumFound(); |
---|
| 20 | |
---|
| 21 | // show documents using the resultset iterator |
---|
| 22 | foreach ($resultset as $document) { |
---|
| 23 | |
---|
| 24 | echo '<hr/><table>'; |
---|
| 25 | echo '<tr><th>id</th><td>' . $document->id . '</td></tr>'; |
---|
| 26 | echo '<tr><th>name</th><td>' . $document->name . '</td></tr>'; |
---|
| 27 | echo '<tr><th>price</th><td>' . $document->price . '</td></tr>'; |
---|
| 28 | echo '</table>'; |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | htmlFooter(); |
---|
Note: See
TracBrowser
for help on using the repository browser.