| 1 | <?php |
||
| 2 | |||
| 3 | namespace olvlvl\ElasticsearchDSL\Query\Compound; |
||
| 4 | |||
| 5 | use olvlvl\ElasticsearchDSL\Query\QueryAbstract; |
||
| 6 | use olvlvl\ElasticsearchDSL\Query\QueryCollection; |
||
| 7 | |||
| 8 | /** |
||
| 9 | * @property-read QueryCollection $positive |
||
| 10 | * @property-read QueryCollection $negative |
||
| 11 | */ |
||
| 12 | class BoostingQuery extends QueryAbstract |
||
| 13 | { |
||
| 14 | const NAME = 'boosting'; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var QueryCollection |
||
| 18 | */ |
||
| 19 | private $positive; |
||
| 20 | |||
| 21 | protected function get_positive(): QueryCollection |
||
| 22 | { |
||
| 23 | return $this->positive ?: $this->positive = new QueryCollection; |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var QueryCollection |
||
| 28 | */ |
||
| 29 | private $negative; |
||
| 30 | |||
| 31 | protected function get_negative(): QueryCollection |
||
| 32 | { |
||
| 33 | return $this->negative ?: $this->negative = new QueryCollection; |
||
|
0 ignored issues
–
show
|
|||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @var float |
||
| 38 | */ |
||
| 39 | private $negative_boost; |
||
| 40 | |||
| 41 | public function __construct(float $negative_boost = 0.5) |
||
| 42 | { |
||
| 43 | $this->negative_boost = $negative_boost; |
||
| 44 | } |
||
| 45 | |||
| 46 | public function jsonSerialize() |
||
| 47 | { |
||
| 48 | return [ self::NAME => array_filter([ |
||
| 49 | |||
| 50 | 'positive' => $this->positive, |
||
| 51 | 'negative' => $this->negative, |
||
| 52 | 'negative_boost' => $this->negative_boost, |
||
| 53 | |||
| 54 | ]) ]; |
||
| 55 | } |
||
| 56 | } |
||
| 57 |