Skip to content

Commit

Permalink
Fixed ResultSet::getTotalCount() issues in previous changeset.
Browse files Browse the repository at this point in the history
  • Loading branch information
parpalak committed Nov 16, 2023
1 parent da1ccff commit 5a56448
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
15 changes: 0 additions & 15 deletions src/S2/Rose/Entity/ResultSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,21 +153,6 @@ public function getSortedRelevanceByExternalId(): array
return $this->sortedRelevance;
}

public function removeDataWithoutToc(): void
{
foreach ($this->data as $serializedExtId => $stat) {
if (!isset($this->items[$serializedExtId])) {
// We found a result just before it was deleted.
// Remove it from the result set.
unset(
$this->data[$serializedExtId],
$this->items[$serializedExtId],
$this->positions[$serializedExtId]
);
}
}
}

/**
* @throws ImmutableException
*/
Expand Down
2 changes: 0 additions & 2 deletions src/S2/Rose/Finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ public function find(Query $query, bool $isDebug = false): ResultSet

$resultSet->addProfilePoint('Fetch TOC');

$resultSet->removeDataWithoutToc();

$relevanceByExternalIds = $resultSet->getSortedRelevanceByExternalId();
if (\count($relevanceByExternalIds) > 0) {
$this->buildSnippets($relevanceByExternalIds, $resultSet);
Expand Down
9 changes: 7 additions & 2 deletions tests/unit/Rose/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,14 @@ public function testFeatures(
$this->assertEquals(new \DateTime('2016-08-20 00:00:00+00:00'), $items[0]->getDate());
$this->assertEquals('This is the second page to be indexed. Let\'s compose something new.', $items[0]->getSnippet(), 'No snippets due to keyword match, no description provided, first sentences are used.');

$resultSet2 = $finder->find(new Query('content'));
$resultSet2 = $finder->find((new Query('content'))->setLimit(2));

$this->assertEquals([
'20:id_2' => 3.8930706202455925,
'20:id_1' => 0.12778564557899275
], $resultSet2->getSortedRelevanceByExternalId());

$this->assertEquals(['20:id_2' => 3.8930706202455925, '10:id_1' => 0.08519043038599518, '20:id_1' => 0.12778564557899275], $resultSet2->getSortedRelevanceByExternalId());
$this->assertEquals(3, $resultSet2->getTotalCount());

$resultSet2 = $finder->find(new Query('content'));

Expand Down

0 comments on commit 5a56448

Please sign in to comment.