This repository has been archived by the owner on Feb 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.php
executable file
·78 lines (60 loc) · 1.72 KB
/
test.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
require __DIR__ . '/vendor/autoload.php';
echo 'Solarium ' . Solarium\Client::VERSION . "\n";
$config = array(
'endpoint' => array(
'localhost' => array(
'host' => '127.0.0.1',
'port' => 8983,
'path' => '/',
'core' => 'igo'
)
)
);
$client = new Solarium\Client(
new Solarium\Core\Client\Adapter\Curl(),
new Symfony\Component\EventDispatcher\EventDispatcher(),
$config);
function ping($client) {
$ping = $client->createPing();
$result = $client->ping($ping);
}
function indexDocument($client, $fileName, $fileID, $date) {
$query = $client->createExtract();
$query->setFile(__DIR__ . '/' . $fileName);
$query->setCommit(true);
$query->setOmitHeader(false);
$doc = $query->createDocument();
$doc->setField('id', $fileID);
$doc->setField('date', $date);
$query->setDocument($doc);
$result = $client->extract($query);
echo $fileName . "\n";
}
function query1($client) {
$query = $client->createSelect();
$query->setQuery('virtueel');
return $client->select($query);
}
function query2($client) {
$query = $client->createSelect();
$query->setQuery('BOSA');
$query->createFilterQuery('maxdate')->setQuery('date:[* TO 2020-01-01T00:00:00Z]');
return $client->select($query);
}
function showResults($resultset) {
echo 'Found: ' . $resultset->getNumFound() . "\n";
foreach ($resultset as $doc) {
echo 'ID: ' . $doc->id . "\n";
foreach ($doc as $key => $value) {
if (is_array($value)) {
$value = implode(', ', $value);
}
echo "\t" . $key . '=' . $value . "\n";
}
}
}
indexDocument($client, 'opendataportals_201904_nl.pdf', 'od2019', '2019-04-29');
indexDocument($client, 'opendataportals_202005_nl.pdf', 'od2020', '2020-05-01');
showResults(query1($client));
showResults(query2($client));