Skip to content

Commit

Permalink
Allow getSourceItem to return non array values + make root filter opt…
Browse files Browse the repository at this point in the history
…ional
  • Loading branch information
pionl committed Apr 16, 2020
1 parent 30edf51 commit 7abacad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/Search/Query/AbstractBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public function __construct()

// Prepare the underlying query builder
$this->query = new QueryBuilder();
$this->query->addFilter($this->filter);
}

abstract protected function createIndex(): AbstractElasticIndex;
Expand All @@ -74,6 +73,11 @@ public function paginate()
$this->query->setSource($this->select);
}

// Add filter only if it contains any filters.
if (false === $this->filter->isEmpty()) {
$this->query->addFilter($this->filter);
}

// Build the query and improve it
$query = $this->query->getQuery();

Expand Down
4 changes: 2 additions & 2 deletions src/Search/Query/Traits/ParseResultsFromHits.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ protected function getResultsFromHits(array $hits): array
*
* @param array $result
*
* @return array
* @return array|mixed
*/
protected function getSourceItem(array $result): array
protected function getSourceItem(array $result)
{
return $result['_source'];
}
Expand Down

0 comments on commit 7abacad

Please sign in to comment.