Skip to content

Commit 267a69e

Browse files
committed
feat: add missing params in SearchQuery
1 parent 3bfcda0 commit 267a69e

2 files changed

Lines changed: 61 additions & 1 deletion

File tree

src/Contracts/SearchQuery.php

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,13 @@ class SearchQuery
111111

112112
private ?FederationOptions $federationOptions = null;
113113

114+
private ?bool $retrieveVectors = null;
115+
116+
/**
117+
* @var array<string, mixed>|null
118+
*/
119+
private ?array $media = null;
120+
114121
/**
115122
* @return $this
116123
*/
@@ -429,6 +436,36 @@ public function setAttributesToSearchOn(array $attributesToSearchOn): self
429436
return $this;
430437
}
431438

439+
public function getRetrieveVectors(): ?bool
440+
{
441+
return $this->retrieveVectors;
442+
}
443+
444+
public function setRetrieveVectors(?bool $retrieveVectors): self
445+
{
446+
$this->retrieveVectors = $retrieveVectors;
447+
448+
return $this;
449+
}
450+
451+
/**
452+
* @return array<string, mixed>|null
453+
*/
454+
public function getMedia(): ?array
455+
{
456+
return $this->media;
457+
}
458+
459+
/**
460+
* @param array<string, mixed>|null $media
461+
*/
462+
public function setMedia(?array $media): self
463+
{
464+
$this->media = $media;
465+
466+
return $this;
467+
}
468+
432469
/**
433470
* @return array{
434471
* indexUid?: non-empty-string,
@@ -457,7 +494,9 @@ public function setAttributesToSearchOn(array $attributesToSearchOn): self
457494
* showRankingScoreDetails?: bool,
458495
* rankingScoreThreshold?: float,
459496
* distinct?: non-empty-string,
460-
* federationOptions?: array<mixed>
497+
* federationOptions?: array<mixed>,
498+
* retrieveVectors?: bool,
499+
* media?: array<string, mixed>,
461500
* }
462501
*/
463502
public function toArray(): array
@@ -490,6 +529,8 @@ public function toArray(): array
490529
'rankingScoreThreshold' => $this->rankingScoreThreshold,
491530
'distinct' => $this->distinct,
492531
'federationOptions' => null !== $this->federationOptions ? $this->federationOptions->toArray() : null,
532+
'retrieveVectors' => $this->retrieveVectors,
533+
'media' => $this->media,
493534
], static function ($item) { return null !== $item; });
494535
}
495536
}

tests/Contracts/SearchQueryTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,4 +236,23 @@ public function testSetFederationOptions(): void
236236

237237
self::assertSame(['federationOptions' => ['weight' => 0.5]], $data->toArray());
238238
}
239+
240+
/**
241+
* @testWith [true]
242+
* [false]
243+
*/
244+
public function testSetRetrieveVectors(bool $retrieveVectors): void
245+
{
246+
$data = (new SearchQuery())->setRetrieveVectors($retrieveVectors);
247+
248+
self::assertSame(['retrieveVectors' => $retrieveVectors], $data->toArray());
249+
}
250+
251+
public function testSetMedia(): void
252+
{
253+
$media = ['image' => ['mime' => 'image/jpeg', 'data' => 'data://foo:bar']];
254+
$data = (new SearchQuery())->setMedia($media);
255+
256+
self::assertSame(['media' => $media], $data->toArray());
257+
}
239258
}

0 commit comments

Comments
 (0)