diff --git a/src/SearchEndpoint/QueryEndpoint.php b/src/SearchEndpoint/QueryEndpoint.php index f723e92e37845cf24041e85cb84cb392223dfbdd..9f14df543c3a4c0f3f463501901c97987a65b40c 100644 --- a/src/SearchEndpoint/QueryEndpoint.php +++ b/src/SearchEndpoint/QueryEndpoint.php @@ -37,20 +37,24 @@ class QueryEndpoint extends AbstractSearchEndpoint implements OrderedNormalizerI */ public function normalize(NormalizerInterface $normalizer, $format = null, array $context = []) { + $query = $this->getBool(); + if ($this->hasReference('filtered_query')) { /** @var FilteredQuery $filteredQuery */ $filteredQuery = $this->getReference('filtered_query'); - $this->add($filteredQuery); + + if ($query) { + $filteredQuery->setQuery($query); + } + + $query = $filteredQuery; } - if (!$this->bool) { + if (!$query) { return null; } - $queryArray = $this->bool->toArray(); - $queryArray = [$this->bool->getType() => $queryArray]; - - return $queryArray; + return [$query->getType() => $query->toArray()]; } /**