Skip to content
This repository was archived by the owner on Jun 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Result/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,16 @@ public function getSubresults(): array
return $this->subresults;
}

/**
* @param array $subResults
*
* @return array
*/
public function setSubResults(array $subResults)
{
$this->subresults = $subResults;
}

/**
* Set metadata.
*
Expand Down
13 changes: 13 additions & 0 deletions Tests/Result/ResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,19 @@ public function testMultiResult()
$this->assertEquals(3, $subqueries['res1']->getTotalHits());
$this->assertEquals(4, $subqueries['res2']->getTotalHits());
$this->assertEquals(5, $subqueries['res3']->getTotalHits());

$result = Result::createFromArray([]);
$result->setSubResults([
'res1' => Result::create(Query::createMatchAll()->identifyWith('1'), 10, 3, null, [], []),
'res2' => Result::create(Query::createMatchAll()->identifyWith('2'), 10, 4, null, [], []),
'res3' => Result::create(Query::createMatchAll()->identifyWith('3'), 10, 5, null, [], []),
]);

$this->assertCount(3, $result->getSubresults());
$subqueries = HttpHelper::emulateHttpTransport($result)->getSubresults();
$this->assertEquals(3, $subqueries['res1']->getTotalHits());
$this->assertEquals(4, $subqueries['res2']->getTotalHits());
$this->assertEquals(5, $subqueries['res3']->getTotalHits());
}

/**
Expand Down