diff --git a/src/Contracts/SearchQuery.php b/src/Contracts/SearchQuery.php index da71dc2e..ea7891fd 100644 --- a/src/Contracts/SearchQuery.php +++ b/src/Contracts/SearchQuery.php @@ -111,6 +111,13 @@ class SearchQuery private ?FederationOptions $federationOptions = null; + private ?bool $retrieveVectors = null; + + /** + * @var array|null + */ + private ?array $media = null; + /** * @return $this */ @@ -429,6 +436,29 @@ public function setAttributesToSearchOn(array $attributesToSearchOn): self return $this; } + public function setRetrieveVectors(?bool $retrieveVectors): self + { + $this->retrieveVectors = $retrieveVectors; + + return $this; + } + + /** + * This is an EXPERIMENTAL feature, which may break without a major version. + * It's available from Meilisearch v1.16. + * To enable it properly and use multimodal search, it's required to activate it through the /experimental-features route. + * + * More info: https://www.meilisearch.com/docs/reference/api/experimental-features + * + * @param array|null $media + */ + public function setMedia(?array $media): self + { + $this->media = $media; + + return $this; + } + /** * @return array{ * indexUid?: non-empty-string, @@ -457,7 +487,9 @@ public function setAttributesToSearchOn(array $attributesToSearchOn): self * showRankingScoreDetails?: bool, * rankingScoreThreshold?: float, * distinct?: non-empty-string, - * federationOptions?: array + * federationOptions?: array, + * retrieveVectors?: bool, + * media?: array, * } */ public function toArray(): array @@ -490,6 +522,8 @@ public function toArray(): array 'rankingScoreThreshold' => $this->rankingScoreThreshold, 'distinct' => $this->distinct, 'federationOptions' => null !== $this->federationOptions ? $this->federationOptions->toArray() : null, + 'retrieveVectors' => $this->retrieveVectors, + 'media' => $this->media, ], static function ($item) { return null !== $item; }); } } diff --git a/tests/Contracts/SearchQueryTest.php b/tests/Contracts/SearchQueryTest.php index 992a0a8c..f1e86364 100644 --- a/tests/Contracts/SearchQueryTest.php +++ b/tests/Contracts/SearchQueryTest.php @@ -236,4 +236,23 @@ public function testSetFederationOptions(): void self::assertSame(['federationOptions' => ['weight' => 0.5]], $data->toArray()); } + + /** + * @testWith [true] + * [false] + */ + public function testSetRetrieveVectors(bool $retrieveVectors): void + { + $data = (new SearchQuery())->setRetrieveVectors($retrieveVectors); + + self::assertSame(['retrieveVectors' => $retrieveVectors], $data->toArray()); + } + + public function testSetMedia(): void + { + $media = ['image' => ['mime' => 'image/jpeg', 'data' => 'data://foo:bar']]; + $data = (new SearchQuery())->setMedia($media); + + self::assertSame(['media' => $media], $data->toArray()); + } }