Revision 7576,
1.4 KB
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 | require('init.php'); |
---|
3 | |
---|
4 | htmlHeader(); |
---|
5 | |
---|
6 | // create a client instance and autoload the customize request plugin |
---|
7 | $client = new Solarium_Client($config); |
---|
8 | $customizer = $client->getPlugin('customizerequest'); |
---|
9 | |
---|
10 | // add a persistent HTTP header (using array input values) |
---|
11 | $customizer->createCustomization(array( |
---|
12 | 'key' => 'auth', |
---|
13 | 'type' => 'header', |
---|
14 | 'name' => 'X-my-auth', |
---|
15 | 'value' => 'mypassword', |
---|
16 | 'persistent' => true |
---|
17 | )); |
---|
18 | |
---|
19 | // add a persistent GET param (using fluent interface) |
---|
20 | $customizer->createCustomization('session') |
---|
21 | ->setType('param') |
---|
22 | ->setName('ssid') |
---|
23 | ->setValue('md7Nhd86adye6sad46d') |
---|
24 | ->setPersistent(true); |
---|
25 | |
---|
26 | // add a GET param thats only used for a single request (the default setting is no persistence) |
---|
27 | $customizer->createCustomization('id') |
---|
28 | ->setType('param') |
---|
29 | ->setName('id') |
---|
30 | ->setValue(4576); |
---|
31 | |
---|
32 | // create a basic query to execute |
---|
33 | $query = $client->createSelect(); |
---|
34 | |
---|
35 | // execute query (you should be able to see the extra params in the solr log file) |
---|
36 | $resultset = $client->select($query); |
---|
37 | |
---|
38 | // display the total number of documents found by solr |
---|
39 | echo 'NumFound: '.$resultset->getNumFound() . '<br/>'; |
---|
40 | |
---|
41 | // execute the same query again (this time the 'id' param should no longer show up in the logs) |
---|
42 | $resultset = $client->select($query); |
---|
43 | |
---|
44 | // display the total number of documents found by solr |
---|
45 | echo 'NumFound: '.$resultset->getNumFound(); |
---|
46 | |
---|
47 | htmlFooter(); |
---|
Note: See
TracBrowser
for help on using the repository browser.