Skip to content
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

Add searchCutoffMs method #636

Merged
merged 1 commit into from
May 2, 2024
Merged
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
17 changes: 17 additions & 0 deletions src/Endpoints/Delegates/HandlesSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,23 @@ public function resetProximityPrecision(): array
return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/proximity-precision');
}

// Settings - searchCutoffMs

public function getSearchCutoffMs(): ?int
{
return $this->http->get(self::PATH.'/'.$this->uid.'/settings/search-cutoff-ms');
}

public function updateSearchCutoffMs(int $value): array
{
return $this->http->put(self::PATH.'/'.$this->uid.'/settings/search-cutoff-ms', $value);
brunoocasali marked this conversation as resolved.
Show resolved Hide resolved
}

public function resetSearchCutoffMs(): array
{
return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/search-cutoff-ms');
}

// Settings - Experimental: Embedders (hybrid search)

public function getEmbedders(): ?array
Expand Down
49 changes: 49 additions & 0 deletions tests/Settings/SearchCutoffMsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

declare(strict_types=1);

namespace Tests\Settings;

use Meilisearch\Endpoints\Indexes;
use Tests\TestCase;

final class SearchCutoffMsTest extends TestCase
{
private Indexes $index;

protected function setUp(): void
{
parent::setUp();
$this->index = $this->createEmptyIndex($this->safeIndexName());
}

public function testGetDefaultSearchCutoffMs(): void
{
$default = $this->index->getSearchCutoffMs();

self::assertNull($default);
}

public function testUpdateSearchCutoffMs(): void
{
$promise = $this->index->updateSearchCutoffMs(50);
$this->assertIsValidPromise($promise);
$this->index->waitForTask($promise['taskUid']);

self::assertSame(50, $this->index->getSearchCutoffMs());
}

public function testResetSearchCutoffMs(): void
{
$promise = $this->index->updateSearchCutoffMs(50);
$this->assertIsValidPromise($promise);
$this->index->waitForTask($promise['taskUid']);

$promise = $this->index->resetSearchCutoffMs();

$this->assertIsValidPromise($promise);
$this->index->waitForTask($promise['taskUid']);

self::assertNull($this->index->getSearchCutoffMs());
}
}