Revision 7588,
1.0 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
|
Line | |
---|
1 | <?php |
---|
2 | |
---|
3 | require_once 'Zend/Loader/Autoloader.php'; |
---|
4 | $loader = Zend_Loader_Autoloader::getInstance(); |
---|
5 | |
---|
6 | require('init.php'); |
---|
7 | htmlHeader(); |
---|
8 | |
---|
9 | // create a client instance |
---|
10 | $client = new Solarium_Client($config); |
---|
11 | |
---|
12 | // set the adapter to peclhttp |
---|
13 | $client->setAdapter('Solarium_Client_Adapter_PeclHttp'); |
---|
14 | |
---|
15 | // get a select query instance |
---|
16 | $query = $client->createSelect(); |
---|
17 | |
---|
18 | // this executes the query and returns the result |
---|
19 | $resultset = $client->select($query); |
---|
20 | |
---|
21 | // display the total number of documents found by solr |
---|
22 | echo 'NumFound: '.$resultset->getNumFound(); |
---|
23 | |
---|
24 | // show documents using the resultset iterator |
---|
25 | foreach ($resultset as $document) { |
---|
26 | |
---|
27 | echo '<hr/><table>'; |
---|
28 | |
---|
29 | // the documents are also iterable, to get all fields |
---|
30 | foreach($document AS $field => $value) |
---|
31 | { |
---|
32 | // this converts multivalue fields to a comma-separated string |
---|
33 | if(is_array($value)) $value = implode(', ', $value); |
---|
34 | |
---|
35 | echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>'; |
---|
36 | } |
---|
37 | |
---|
38 | echo '</table>'; |
---|
39 | } |
---|
40 | |
---|
41 | htmlFooter(); |
---|
Note: See
TracBrowser
for help on using the repository browser.