Skip to content

Commit

Permalink
Remove null from rankingScoreThreshold
Browse files Browse the repository at this point in the history
  • Loading branch information
the-sinner committed Jun 11, 2024
1 parent 490bf71 commit 2fe0b2f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Contracts/SearchQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public function toArray(): array
'attributesToSearchOn' => $this->attributesToSearchOn,
'showRankingScore' => $this->showRankingScore,
'showRankingScoreDetails' => $this->showRankingScoreDetails,
'rankingScoreThreshold' => $this->rankingScoreThreshold ?? null,
'rankingScoreThreshold' => $this->rankingScoreThreshold,
], function ($item) { return null !== $item; });
}
}
9 changes: 5 additions & 4 deletions src/Contracts/SimilarDocumentsQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class SimilarDocumentsQuery
{
private int|string $id;
private $id;
private ?int $offset = null;
private ?int $limit = null;
private ?string $embedder = null;
Expand All @@ -15,11 +15,12 @@ class SimilarDocumentsQuery
private ?bool $showRankingScoreDetails = null;
private ?array $filter = null;

public function setId(string|int $id): SimilarDocumentsQuery
/**
* @param int|string $id
*/
public function __construct($id)
{
$this->id = $id;

return $this;
}

public function setOffset(?int $offset): SimilarDocumentsQuery
Expand Down
5 changes: 1 addition & 4 deletions tests/Endpoints/SimilarDocumentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ public function testBasicSearchWithSimilarDocuments(): void
self::assertSame(1, $response->getHitsCount());

$documentId = $response->getHit(0)['id'];
$response = $this->index->searchSimilarDocuments(
(new SimilarDocumentsQuery())
->setId($documentId)
);
$response = $this->index->searchSimilarDocuments(new SimilarDocumentsQuery($documentId));

self::assertGreaterThanOrEqual(4, $response->getHitsCount());
self::assertArrayHasKey('_vectors', $response->getHit(0));
Expand Down

0 comments on commit 2fe0b2f

Please sign in to comment.