| 1 | <?php |
||
| 11 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-parent-id-query.html |
||
| 12 | */ |
||
| 13 | class ParentIdQuery implements BuilderInterface |
||
| 14 | { |
||
| 15 | use ParametersTrait; |
||
| 16 | |||
| 17 | public function __construct( |
||
| 18 | private string $parentId, |
||
|
|
|||
| 19 | private string $childType, |
||
| 20 | array $parameters = [] |
||
| 21 | ) { |
||
| 22 | $this->setParameters($parameters); |
||
| 23 | } |
||
| 24 | |||
| 25 | public function getType(): string |
||
| 26 | { |
||
| 27 | return 'parent_id'; |
||
| 28 | } |
||
| 29 | |||
| 30 | public function toArray(): array |
||
| 31 | { |
||
| 32 | $query = [ |
||
| 33 | 'id' => $this->parentId, |
||
| 34 | 'type' => $this->childType, |
||
| 35 | ]; |
||
| 36 | $output = $this->processArray($query); |
||
| 37 | |||
| 38 | return [$this->getType() => $output]; |
||
| 39 | } |
||
| 40 | } |
||
| 41 |