forked from solariumphp/solarium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
7.3-plugin-customizerequest.php
49 lines (38 loc) · 1.46 KB
/
7.3-plugin-customizerequest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
require(__DIR__.'/init.php');
htmlHeader();
// create a client instance and autoload the customize request plugin
$client = new Solarium\Client($config);
$customizer = $client->getPlugin('customizerequest');
// add a persistent HTTP header (using array input values)
$customizer->createCustomization(
array(
'key' => 'auth',
'type' => 'header',
'name' => 'X-my-auth',
'value' => 'mypassword',
'persistent' => true
)
);
// add a persistent GET param (using fluent interface)
$customizer->createCustomization('session')
->setType('param')
->setName('ssid')
->setValue('md7Nhd86adye6sad46d')
->setPersistent(true);
// add a GET param thats only used for a single request (the default setting is no persistence)
$customizer->createCustomization('id')
->setType('param')
->setName('id')
->setValue(4576);
// create a basic query to execute
$query = $client->createSelect();
// execute query (you should be able to see the extra params in the solr log file)
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'NumFound: '.$resultset->getNumFound() . '<br/>';
// execute the same query again (this time the 'id' param should no longer show up in the logs)
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'NumFound: '.$resultset->getNumFound();
htmlFooter();