1 | <?php |
||
21 | * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html |
||
22 | */ |
||
23 | class BoostingQuery implements BuilderInterface |
||
24 | { |
||
25 | public function __construct( |
||
26 | private BuilderInterface $positive, |
||
|
|||
27 | private BuilderInterface $negative, |
||
28 | private int|float $negativeBoost |
||
29 | ) { |
||
30 | |||
31 | } |
||
32 | |||
33 | public function getType(): string |
||
34 | { |
||
35 | return 'boosting'; |
||
36 | } |
||
37 | |||
38 | public function toArray(): array |
||
39 | { |
||
40 | $query = [ |
||
41 | 'positive' => $this->positive->toArray(), |
||
42 | 'negative' => $this->negative->toArray(), |
||
43 | 'negative_boost' => $this->negativeBoost, |
||
44 | ]; |
||
45 | |||
46 | return [$this->getType() => $query]; |
||
47 | } |
||
48 | } |
||
49 |