Skip to content

Build your personal knowledge base with Trilium Notes

refactor(search): simplify branching for autocomplete

Elian Doran47ce77e04cbc
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);