Newer
Older
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
<?php
namespace IQDEV\ElasticSearch\Search;
use IQDEV\ElasticSearch\Esable;
use IQDEV\ElasticSearch\Search\BoolQuery\Query;
class Nested implements Esable
{
protected ?string $path = null;
protected ?Query $query = null;
public function __construct()
{
}
public function setPath(string $p): self
{
$this->path = $p;
return $this;
}
public function setQuery(Query $q): self
{
$this->query = $q;
return $this;
}
public function es(): array
{
$nested = [];
if ($this->path) {
$nested['path'] = $this->path;
}
if (isset($this->query) && $this->query->isEmpty() === false) {
$nested['query'] = $this->query->es()['query'];
}
return ['nested' => $nested];
}
}