Skip to content

Commit

Permalink
Add searchCutoffMs methods (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoocasali authored May 2, 2024
1 parent 68e4868 commit 7481607
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
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);
}

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());
}
}

0 comments on commit 7481607

Please sign in to comment.