diff --git a/src/S2/Rose/Entity/ResultSet.php b/src/S2/Rose/Entity/ResultSet.php index d2ff4a5..bba05c7 100644 --- a/src/S2/Rose/Entity/ResultSet.php +++ b/src/S2/Rose/Entity/ResultSet.php @@ -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 */ diff --git a/src/S2/Rose/Finder.php b/src/S2/Rose/Finder.php index e4d5c26..dd993ce 100644 --- a/src/S2/Rose/Finder.php +++ b/src/S2/Rose/Finder.php @@ -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); diff --git a/tests/unit/Rose/IntegrationTest.php b/tests/unit/Rose/IntegrationTest.php index 189275e..ff8703e 100644 --- a/tests/unit/Rose/IntegrationTest.php +++ b/tests/unit/Rose/IntegrationTest.php @@ -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'));