Skip to content

Commit c5b229c

Browse files
Merge #701
701: Ensure that hitsCount value is always consistent r=curquiza a=johnnynotsolucky # Pull Request ## Related issue Fixes #700 ## What does this PR do? - Ensures that `SearchResults::hitsCount` is consistent regardless of whether `estimatedTotalHits` is set. ## PR checklist Please check if your PR fulfills the following requirements: - [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)? - [x] Have you read the contributing guidelines? - [x] Have you made sure that the title is accurate and descriptive of the changes? Thank you so much for contributing to Meilisearch! Co-authored-by: Tyrone Tudehope <[email protected]>
2 parents a1a414e + 2e80226 commit c5b229c

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/Search/SearchResult.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,18 @@ public function __construct(array $body)
5858
$this->offset = $body['offset'];
5959
$this->limit = $body['limit'];
6060
$this->estimatedTotalHits = $body['estimatedTotalHits'];
61-
$this->hitsCount = \count($body['hits']);
6261
} else {
6362
$this->numberedPagination = true;
6463

6564
$this->hitsPerPage = $body['hitsPerPage'];
6665
$this->page = $body['page'];
6766
$this->totalPages = $body['totalPages'];
6867
$this->totalHits = $body['totalHits'];
69-
$this->hitsCount = $body['totalHits'];
7068
}
7169

7270
$this->semanticHitCount = $body['semanticHitCount'] ?? 0;
7371
$this->hits = $body['hits'] ?? [];
72+
$this->hitsCount = \count($body['hits']);
7473
$this->processingTimeMs = $body['processingTimeMs'];
7574
$this->query = $body['query'];
7675
$this->facetDistribution = $body['facetDistribution'] ?? [];

0 commit comments

Comments
 (0)