See More

query = $query; $this->filter = $filter; $this->postFilter = $postFilter; $this->sort = $sort; $this->aggregation = $aggregation; $this->options = $options; } public function query(): \Spameri\ElasticQuery\Query\QueryCollection { return $this->query; } public function filter(): \Spameri\ElasticQuery\Filter\FilterCollection { return $this->filter; } public function aggregation(): \Spameri\ElasticQuery\Aggregation\AggregationCollection { return $this->aggregation; } public function options(): \Spameri\ElasticQuery\Options { return $this->options; } public function highlight(): \Spameri\ElasticQuery\Highlight|null { return $this->highlight; } public function functionScore(): \Spameri\ElasticQuery\FunctionScore|null { return $this->functionScore; } public function addMustQuery(\Spameri\ElasticQuery\Query\LeafQueryInterface $leafQuery): void { $this->query->must()->add($leafQuery); } public function addMustNotQuery(\Spameri\ElasticQuery\Query\LeafQueryInterface $leafQuery): void { $this->query->mustNot()->add($leafQuery); } public function addShouldQuery(\Spameri\ElasticQuery\Query\LeafQueryInterface $leafQuery): void { $this->query->should()->add($leafQuery); } public function postFilter(): \Spameri\ElasticQuery\Query\QueryCollection { return $this->postFilter; } public function addPostFilterMustQuery(\Spameri\ElasticQuery\Query\LeafQueryInterface $leafQuery): void { $this->postFilter->must()->add($leafQuery); } public function addFilter(\Spameri\ElasticQuery\Query\LeafQueryInterface $leafQuery): void { $this->filter->must()->add($leafQuery); } public function addAggregation(\Spameri\ElasticQuery\Aggregation\LeafAggregationCollection $aggregation): void { $this->aggregation->add($aggregation); } public function toArray(): array { $array = $this->options->toArray(); $queryArray = $this->query->toArray(); if ($queryArray) { $array['query'] = $queryArray; } if ($this->functionScore !== null) { $array['query'] = $this->functionScore->toArray($array['query']); } $filterArray = $this->filter->toArray(); if ($filterArray) { $array['query']['bool']['filter'] = $filterArray; } $postFilterArray = $this->postFilter->toArray(); if ($postFilterArray) { $array['post_filter'] = $postFilterArray; } $sortArray = $this->sort->toArray(); if ($sortArray) { $array['sort'] = $sortArray; } $aggregation = $this->aggregation->toArray(); if ($aggregation) { $array['aggs'] = $aggregation; } if ($this->highlight !== null) { $array['highlight'] = $this->highlight->toArray(); } return $array; } }