-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
61 lines (54 loc) · 1.42 KB
/
index.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
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once __DIR__ . '/vendor/autoload.php';
use ES\ES;
/**
* Временный конфиг
*/
const CONFIG = [
'hosts' => [
'host:9206',
],
'types' => [
'advert' => 'advert',
'comment' => 'comment',
'suggestion' => 'suggestion',
'region' => 'region',
'region-polygon' => 'region-polygon',
],
'indexes' => [
'advert' => 'adverts',
'comment' => 'comments',
'suggestion' => 'suggestions',
'region' => 'regions',
'region-polygon' => 'region-polygons',
],
];
//инициализация синглтона ESB
ES::init(CONFIG);
$result = ES::search('advert')
->query(
ES::and(
null,
ES::where('system_data.storage_id', 'archive'),
ES::where('system_data.free_weeks', [2,3])
)
)
->limit(0, 0)
->aggs(
ES::aggs(
ES::aggsTerm('emails', 'email', 20000),
ES::aggs(
ES::aggsMax('ids', 'id')
)
)
)
->sort(['id' => 'desc'])
->fields(['id', 'data.email'])
->result();
//header('content-type: application/json');
//echo json_encode($search->query->toArray()); die();
dd($result->getResponse()->getData());
header('content-type: application/json');
echo json_encode($result);