From 6699c8cb58999f0b9928e2d61f873c7a3a541d6a Mon Sep 17 00:00:00 2001 From: Bart van Bragt Date: Thu, 9 Apr 2026 08:43:15 +0200 Subject: [PATCH] fix: ngram min_gram=1 indexes tokens that can never be matched Flarum's search UI enforces a minimum query length of 3 characters (MIN_SEARCH_LEN in Search.tsx), so 1- and 2-character ngram tokens are indexed but can never be queried. Changed min_gram from 1 to 3 and updated max_ngram_diff accordingly. --- src/Commands/BuildCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/BuildCommand.php b/src/Commands/BuildCommand.php index 554e0f9..7a97377 100644 --- a/src/Commands/BuildCommand.php +++ b/src/Commands/BuildCommand.php @@ -87,7 +87,7 @@ class BuildCommand extends Command 'index' => $index, 'body' => [ 'settings' => [ - 'index.max_ngram_diff' => 10, + 'index.max_ngram_diff' => 7, 'analysis' => [ 'analyzer' => [ 'flarum_analyzer' => [ @@ -105,7 +105,7 @@ class BuildCommand extends Command 'filter' => [ 'partial_search_filter' => [ 'type' => 'ngram', - 'min_gram' => 1, + 'min_gram' => 3, 'max_gram' => 10, 'token_chars' => ['letter', 'digit', 'symbol'], ],