| 1 | <?php |
||
| 28 | * the metadata fields. All extracted fields are then combined to build a query. |
||
| 29 | */ |
||
| 30 | class MultiMatchQuery implements BuilderInterface |
||
| 31 | { |
||
| 32 | use ParametersTrait; |
||
| 33 | |||
| 34 | public function __construct( |
||
| 35 | private array $fields, |
||
|
|
|||
| 36 | private string $query, |
||
| 37 | array $parameters = [] |
||
| 38 | ) { |
||
| 39 | $this->setParameters($parameters); |
||
| 40 | } |
||
| 41 | |||
| 42 | public function getType(): string |
||
| 43 | { |
||
| 44 | return 'multi_match'; |
||
| 45 | } |
||
| 46 | |||
| 47 | public function toArray(): array |
||
| 48 | { |
||
| 49 | $query = [ |
||
| 50 | 'query' => $this->query, |
||
| 51 | ]; |
||
| 52 | if (count($this->fields)) { |
||
| 53 | $query['fields'] = $this->fields; |
||
| 54 | } |
||
| 55 | |||
| 56 | $output = $this->processArray($query); |
||
| 57 | |||
| 58 | return [$this->getType() => $output]; |
||
| 59 | } |
||
| 60 | } |
||
| 61 |