-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfsESHandler.php
More file actions
55 lines (49 loc) · 1.04 KB
/
fsESHandler.php
File metadata and controls
55 lines (49 loc) · 1.04 KB
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
<?php
require 'vendor/autoload.php';
class esCallHandler {
private $handler;
private $callindex,$calltype;
function __construct($hosts,$callid,$callindex) {
$this->handler = Elasticsearch\ClientBuilder::create()
->setHosts($hosts)
->build();
$this->callindex = $callid;
$this->calltype = $callindex;
}
function getViaUuid($uuid) {
$params = [
'index' => $this->callindex,
'type' => $this->calltype,
'id' => $uuid,
'client' => [ 'ignore' => 404 ]
];
try {
$response = $this->handler->get($params);
} catch (Exception $e) {
echo $e->getMessage(),"\n";
return NULL;
}
return $response;
}
function searchField($field,$data) {
$params = [
'index' => $this->callindex,
'type' => $this->calltype,
'body' => [
'query' => [
'match' => [
$field => $data
]
]
]
];
try {
$results = $this->handler->search($params);
return $results;
} catch (Exception $e) {
echo $e->getMessage(),"\n";
return NULL;
}
}
}
?>