Skip to content

Commit

Permalink
fix: set query var for use in yielding documents
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Taylor-Jackson committed Jan 13, 2018
1 parent 563f1dd commit b495c92
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/DesignMyNight/Elasticsearch/QueryProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public function processSelect(Builder $query, $results)

$this->aggregations = $results['aggregations'] ?? [];

$this->query = $query;

// Return a generator if we got a scroll cursor in the results
if (isset($results['_scroll_id'])){
return $this->yieldResults($results);
Expand All @@ -50,13 +52,13 @@ protected function yieldResults($results): Generator
{
// First yield each result from the initial request
foreach ($results['hits']['hits'] as $result){
yield $this->documentFromResult($query, $result);
yield $this->documentFromResult($this->query, $result);
}

// Then go through the scroll cursor getting one result at a time
if (isset($results['scrollCursor'])){
foreach ($results['scrollCursor'] as $result){
$document = $this->documentFromResult($query, $result);
$document = $this->documentFromResult($this->query, $result);

yield $document;
}
Expand Down

0 comments on commit b495c92

Please sign in to comment.