forked from roaatech/php-es-mapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcase2.php
36 lines (31 loc) · 993 Bytes
/
case2.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
<?php
/* * ***
* All the examples suppose there is an ES instance with the following
* index/type/doc architecture:
*
* - tests
* - foo
* - foo1: {name: Fooa, id: 1, age: 33, alive: true}
* - foo2: {name: Foob, id: 2, age: 18, alive: false}
* - bar
* - bar1: {name: Bara, id: 1, age: 33, alive: true}
* - bar2: {name: Barb, id: 2, age: 77, alive: false}
* - bar3: {name: Barc, id: 3, age: 12, alive: false}
*/
require '../vendor/autoload.php';
require_once 'TestsIndexQuery.php';
require_once 'FooTypeQuery.php';
require_once 'BarTypeQuery.php';
require_once 'FooModel.php';
require_once 'BarModel.php';
$result = Tests\FooTypeQuery::query([
"size" => 0,
"aggregations" => [
"alive" => [
"terms" => [
"field" => "alive"
]
]
]
]);
var_dump($result->fetch('aggregations.alive'));