-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Adds hybrid search options contract for multisearch #670
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,33 @@ | ||||||||||||||||||
<?php | ||||||||||||||||||
|
||||||||||||||||||
declare(strict_types=1); | ||||||||||||||||||
|
||||||||||||||||||
namespace MeiliSearch\Contracts; | ||||||||||||||||||
|
||||||||||||||||||
class HybridSearchOptions | ||||||||||||||||||
{ | ||||||||||||||||||
private ?float $semanticRatio = null; | ||||||||||||||||||
private ?string $embedder = null; | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
public function setSemanticRatio(float $ratio): HybridSearchOptions | ||||||||||||||||||
{ | ||||||||||||||||||
$this->semanticRatio = $ratio; | ||||||||||||||||||
|
||||||||||||||||||
return $this; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
public function setEmbedder(string $embedder): HybridSearchOptions | ||||||||||||||||||
apozeus marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
{ | ||||||||||||||||||
$this->embedder = $embedder; | ||||||||||||||||||
|
||||||||||||||||||
return $this; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
public function toArray(): array | ||||||||||||||||||
{ | ||||||||||||||||||
return array_filter([ | ||||||||||||||||||
'semanticRatio' => $this->semanticRatio, | ||||||||||||||||||
'embedder' => $this->embedder, | ||||||||||||||||||
], static function ($item) { return null !== $item; }); | ||||||||||||||||||
} | ||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -27,6 +27,7 @@ | |||||
private ?int $hitsPerPage; | ||||||
private ?int $page; | ||||||
private ?array $vector; | ||||||
private ?HybridSearchOptions $hybrid; | ||||||
Check failure on line 30 in src/Contracts/SearchQuery.php GitHub Actions / phpstan-tests
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was testing it now too. and have made a similar commit. please check. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You've commited it to another PR. so please choose one and close another one. |
||||||
private ?array $attributesToSearchOn = null; | ||||||
private ?bool $showRankingScore = null; | ||||||
private ?bool $showRankingScoreDetails = null; | ||||||
|
@@ -237,6 +238,22 @@ | |||||
return $this; | ||||||
} | ||||||
|
||||||
/** | ||||||
* This is an EXPERIMENTAL feature, which may break without a major version. | ||||||
* | ||||||
* Set hybrid search options | ||||||
* [ | ||||||
* 'semanticRatio'=> 0.8, | ||||||
* 'embedder' => 'manual', | ||||||
* ]; | ||||||
apozeus marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
*/ | ||||||
public function setHybrid(HybridSearchOptions $hybridOptions): SearchQuery | ||||||
Check failure on line 250 in src/Contracts/SearchQuery.php GitHub Actions / phpstan-tests
|
||||||
{ | ||||||
$this->hybrid = $hybridOptions; | ||||||
|
||||||
return $this; | ||||||
} | ||||||
|
||||||
/** | ||||||
* @param list<non-empty-string> $attributesToSearchOn | ||||||
*/ | ||||||
|
@@ -270,6 +287,7 @@ | |||||
'hitsPerPage' => $this->hitsPerPage ?? null, | ||||||
'page' => $this->page ?? null, | ||||||
'vector' => $this->vector ?? null, | ||||||
'hybrid' => null !== $this->hybrid ? $this->hybrid->toArray() : null, | ||||||
'attributesToSearchOn' => $this->attributesToSearchOn, | ||||||
'showRankingScore' => $this->showRankingScore, | ||||||
'showRankingScoreDetails' => $this->showRankingScoreDetails, | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.