for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of PhpStorm.
*
* (c) PHPinnacle Team <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace PHPinnacle\Elastics\Query;
use PHPinnacle\Elastics\Query;
class Boosting implements Query
{
/**
* @var Query
private $positiveQuery;
* @var float
private $positiveBoost;
private $negativeQuery;
private $negativeBoost;
* @param Query $positive
* @param float|null $boost
* @return Boosting
public function positive(Query $positive, float $boost = null): self
$this->positiveQuery = $positive;
$this->positiveBoost = $boost;
return $this;
}
* @param Query $negative
public function negative(Query $negative, float $boost = null): self
$this->negativeQuery = $negative;
$this->negativeBoost = $boost;
* {@inheritdoc}
public function name(): string
return 'boosting';
* @return array
public function compile(): array
$query = [];
if ($this->positiveQuery) {
$query['positive'] = \elastics_compile($this->positiveQuery);
if ($this->positiveBoost !== null) {
$query['boost'] = $this->positiveBoost;
if ($this->negativeQuery) {
$query['negative'] = \elastics_compile($this->negativeQuery);
if ($this->negativeBoost !== null) {
$query['negative_boost'] = $this->negativeBoost;
return $query;