| 1 | <?php |
||
| 22 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-common-terms-query.html |
||
| 23 | */ |
||
| 24 | class CommonTermsQuery implements BuilderInterface |
||
| 25 | { |
||
| 26 | use ParametersTrait; |
||
| 27 | |||
| 28 | public function __construct( |
||
| 29 | private string $field, |
||
|
|
|||
| 30 | private string $query, |
||
| 31 | array $parameters = [] |
||
| 32 | ) { |
||
| 33 | $this->setParameters($parameters); |
||
| 34 | } |
||
| 35 | |||
| 36 | public function getType(): string |
||
| 37 | { |
||
| 38 | return 'common'; |
||
| 39 | } |
||
| 40 | |||
| 41 | public function toArray(): array |
||
| 42 | { |
||
| 43 | $query = [ |
||
| 44 | 'query' => $this->query, |
||
| 45 | ]; |
||
| 46 | |||
| 47 | $output = [ |
||
| 48 | $this->field => $this->processArray($query), |
||
| 49 | ]; |
||
| 50 | |||
| 51 | return [$this->getType() => $output]; |
||
| 52 | } |
||
| 53 | } |
||
| 54 |