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