source: sandbox/expresso-solr/expressoMail1_2/inc/solrclient/examples/2.1.3-filterquery.php @ 7576

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

Line 
1<?php
2
3require('init.php');
4htmlHeader();
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
19echo 'NumFound: '.$resultset->getNumFound();
20
21// show documents using the resultset iterator
22foreach ($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
31htmlFooter();
Note: See TracBrowser for help on using the repository browser.