From 47ce77e04cbcb7855f7577b72b9694fa1062014e Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Mon, 13 Apr 2026 13:05:54 +0300 Subject: [PATCH] refactor(search): simplify branching for autocomplete --- apps/server/src/services/search/services/search.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/apps/server/src/services/search/services/search.ts b/apps/server/src/services/search/services/search.ts index 660c46119b..f9581aa170 100644 --- a/apps/server/src/services/search/services/search.ts +++ b/apps/server/src/services/search/services/search.ts @@ -236,6 +236,12 @@ function findResultsWithExpression(expression: Expression, searchContext: Search loadNeededInfoFromDatabase(); } + // For autocomplete searches, use the dedicated autocomplete fuzzy option + // instead of the global fuzzy setting. + if (searchContext.autocomplete) { + searchContext.enableFuzzyMatching = optionService.getOptionBool("searchAutocompleteFuzzy"); + } + // If there's an explicit orderBy clause, skip progressive search // as it would interfere with the ordering if (searchContext.orderBy) { @@ -249,13 +255,6 @@ function findResultsWithExpression(expression: Expression, searchContext: Search return performSearch(expression, searchContext, false); } - // For autocomplete searches, use the dedicated autocomplete fuzzy option. - // Default is off for faster response; users can enable if they want typo tolerance. - if (searchContext.autocomplete) { - const autocompleteFuzzy = optionService.getOptionBool("searchAutocompleteFuzzy"); - return performSearch(expression, searchContext, autocompleteFuzzy); - } - // Phase 1: Try exact matches first (without fuzzy matching) const exactResults = performSearch(expression, searchContext, false);