Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion src/Contracts/SearchQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ class SearchQuery

private ?FederationOptions $federationOptions = null;

private ?bool $retrieveVectors = null;

/**
* @var array<string, mixed>|null
*/
private ?array $media = null;

/**
* @return $this
*/
Expand Down Expand Up @@ -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<string, mixed>|null $media
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to me mixed looks to broad. also i failed to find any info about this media

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, same 🙁 Maybe @Strift do you have more information on how the media's param is supposed to be structured?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can take a look at how I implemented it in the JS SDK, if that can be helpful: https://github.com/meilisearch/meilisearch-js/pull/1998/files

See src/types/types.ts for the types and tests/multi_modal_search.test.ts for the examples.

*/
public function setMedia(?array $media): self
{
$this->media = $media;

return $this;
}

/**
* @return array{
* indexUid?: non-empty-string,
Expand Down Expand Up @@ -457,7 +487,9 @@ public function setAttributesToSearchOn(array $attributesToSearchOn): self
* showRankingScoreDetails?: bool,
* rankingScoreThreshold?: float,
* distinct?: non-empty-string,
* federationOptions?: array<mixed>
* federationOptions?: array<mixed>,
* retrieveVectors?: bool,
* media?: array<string, mixed>,
* }
*/
public function toArray(): array
Expand Down Expand Up @@ -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; });
}
}
19 changes: 19 additions & 0 deletions tests/Contracts/SearchQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Loading