Skip to content
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
6 changes: 6 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -697,3 +697,9 @@ update_non_separator_tokens_1: |-
$client->index('articles')->updateNonSeparatorTokens(['@', '#']);
reset_non_separator_tokens_1: |-
$client->index('articles')->resetNonSeparatorTokens();
get_proximity_precision_settings_1: |-
$client->index('books')->getProximityPrecision();
update_proximity_precision_settings_1: |-
$client->index('books')->updateProximityPrecision('byAttribute');
reset_proximity_precision_settings_1: |-
$client->index('books')->resetProximityPrecision();
20 changes: 20 additions & 0 deletions src/Endpoints/Delegates/HandlesSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,24 @@ public function resetNonSeparatorTokens(): array
{
return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/non-separator-tokens');
}

// Settings - proximityPrecision

/**
* @return non-empty-string
*/
public function getProximityPrecision(): string
{
return $this->http->get(self::PATH.'/'.$this->uid.'/settings/proximity-precision');
}

public function updateProximityPrecision(string $type): array
{
return $this->http->put(self::PATH.'/'.$this->uid.'/settings/proximity-precision', $type);
}

public function resetProximityPrecision(): array
{
return $this->http->delete(self::PATH.'/'.$this->uid.'/settings/proximity-precision');
}
}
49 changes: 49 additions & 0 deletions tests/Settings/ProximityPrecisionTest.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 ProximityPrecisionTest extends TestCase
{
private Indexes $index;

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

public function testGetDefaultProximityPrecision(): void
{
$default = $this->index->getProximityPrecision();

$this->assertSame('byWord', $default);
}

public function testUpdateProximityPrecision(): void
{
$promise = $this->index->updateProximityPrecision('byAttribute');
$this->assertIsValidPromise($promise);
$this->index->waitForTask($promise['taskUid']);

$this->assertSame('byAttribute', $this->index->getProximityPrecision());
}

public function testResetProximityPrecision(): void
{
$promise = $this->index->updateProximityPrecision('byAttribute');
$this->assertIsValidPromise($promise);
$this->index->waitForTask($promise['taskUid']);

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

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

$this->assertSame('byWord', $this->index->getProximityPrecision());
}
}