1<?php 2 3namespace Elastica\Query; 4 5/** 6 * ParentId query. 7 * 8 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-parent-id-query.html 9 */ 10class ParentId extends AbstractQuery 11{ 12 /** 13 * ParentId constructor. 14 * 15 * @param string $type Name of the child relationship mapped for the join field 16 * @param string $id ID of the parent document. The query will return child documents of this parent document. 17 * @param bool $ignoreUnmapped Indicates whether to ignore an unmapped type and not return any documents instead of an error. Defaults to false. 18 */ 19 public function __construct(string $type, string $id, bool $ignoreUnmapped = false) 20 { 21 $this->setRelationshipType($type); 22 $this->setId($id); 23 $this->setIgnoreUnmapped($ignoreUnmapped); 24 } 25 26 private function setRelationshipType(string $type): void 27 { 28 $this->setParam('type', $type); 29 } 30 31 private function setId(string $id): void 32 { 33 $this->setParam('id', $id); 34 } 35 36 private function setIgnoreUnmapped(bool $ignoreUnmapped = false): void 37 { 38 $this->setParam('ignore_unmapped', $ignoreUnmapped); 39 } 40} 41