From a7077ee4f597d40495578cef03a903e4278eb576 Mon Sep 17 00:00:00 2001 From: Tomas Date: Wed, 8 May 2024 13:49:47 +0300 Subject: [PATCH] SearchCutoffMs setting --- src/DependencyInjection/Configuration.php | 2 +- src/Services/SettingsUpdater.php | 2 +- tests/Integration/CommandsTest.php | 3 +++ tests/config/meilisearch.yaml | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 91cb422b..ea303db4 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -64,7 +64,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->beforeNormalization() ->always() ->then(static function (array $value) { - $stringSettings = ['distinctAttribute', 'proximityPrecision']; + $stringSettings = ['distinctAttribute', 'proximityPrecision', 'searchCutoffMs']; foreach ($stringSettings as $setting) { if (isset($value[$setting]) && !is_array($value[$setting])) { diff --git a/src/Services/SettingsUpdater.php b/src/Services/SettingsUpdater.php index 8584d542..c027d2ba 100644 --- a/src/Services/SettingsUpdater.php +++ b/src/Services/SettingsUpdater.php @@ -58,7 +58,7 @@ public function update(string $indice, ?int $responseTimeout = null): void if (isset($value['_service']) && $value['_service'] instanceof SettingsProvider) { $value = $value['_service'](); - } elseif (('distinctAttribute' === $variable || 'proximityPrecision' === $variable) && is_array($value)) { + } elseif (('distinctAttribute' === $variable || 'proximityPrecision' === $variable || 'searchCutoffMs' === $variable) && is_array($value)) { $value = $value[0] ?? null; } diff --git a/tests/Integration/CommandsTest.php b/tests/Integration/CommandsTest.php index e2972ff6..43adb283 100644 --- a/tests/Integration/CommandsTest.php +++ b/tests/Integration/CommandsTest.php @@ -75,6 +75,7 @@ public function testSearchImportAndClearAndDeleteWithoutIndices(): void Settings updated of "sf_phpunit__posts". Settings updated of "sf_phpunit__posts". Settings updated of "sf_phpunit__posts". +Settings updated of "sf_phpunit__posts". Importing for index Meilisearch\Bundle\Tests\Entity\Comment Importing for index Meilisearch\Bundle\Tests\Entity\Tag Indexed a batch of 6 / 6 Meilisearch\Bundle\Tests\Entity\Tag entities into sf_phpunit__tags index (6 indexed since start) @@ -383,6 +384,7 @@ public function testSearchCreateWithoutIndices(bool $updateSettings): void Settings updated of "sf_phpunit__posts". Settings updated of "sf_phpunit__posts". Settings updated of "sf_phpunit__posts". +Settings updated of "sf_phpunit__posts". Creating index sf_phpunit__comments for Meilisearch\Bundle\Tests\Entity\Comment Creating index sf_phpunit__tags for Meilisearch\Bundle\Tests\Entity\Tag Creating index sf_phpunit__tags for Meilisearch\Bundle\Tests\Entity\Link @@ -434,6 +436,7 @@ public function testSearchCreateWithIndices(): void Settings updated of "sf_phpunit__posts". Settings updated of "sf_phpunit__posts". Settings updated of "sf_phpunit__posts". +Settings updated of "sf_phpunit__posts". Done! EOD, $createOutput); diff --git a/tests/config/meilisearch.yaml b/tests/config/meilisearch.yaml index 7111b886..50a06b90 100644 --- a/tests/config/meilisearch.yaml +++ b/tests/config/meilisearch.yaml @@ -11,6 +11,7 @@ meilisearch: settings: stopWords: ['the', 'a', 'an'] filterableAttributes: ['title', 'publishedAt'] + searchCutoffMs: 1500 typoTolerance: enabled: true disableOnAttributes: ['title']