From fc7a32c04f6b55ac9f1e5f266497f3455d0efa60 Mon Sep 17 00:00:00 2001 From: Nicolas Giard Date: Thu, 13 Nov 2025 15:25:53 -0500 Subject: [PATCH] fix: Simplify error handling in search suggestion logic Refactor error handling for search suggestions to simplify code. --- server/modules/search/postgres/engine.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/server/modules/search/postgres/engine.js b/server/modules/search/postgres/engine.js index dc75ea5c..33204b84 100644 --- a/server/modules/search/postgres/engine.js +++ b/server/modules/search/postgres/engine.js @@ -86,18 +86,8 @@ module.exports = { try { const suggestResults = await WIKI.models.knex.raw(`SELECT word, word <-> ? AS rank FROM "pagesWords" WHERE similarity(word, ?) > 0.2 ORDER BY rank LIMIT 5;`, [q, q]) suggestions = suggestResults.rows.map(r => r.word) - } catch (suggestionErr) { - WIKI.logger.warn('Search Engine Suggestion Error (pg_trgm extension may be missing):') - WIKI.logger.warn(suggestionErr.message) - // Fall back to basic word matching without similarity - try { - const fallbackResults = await WIKI.models.knex.raw(`SELECT word FROM "pagesWords" WHERE word ILIKE ? LIMIT 5;`, [`%${q}%`]) - suggestions = fallbackResults.rows.map(r => r.word) - } catch (fallbackErr) { - WIKI.logger.warn('Search Engine Fallback Error:') - WIKI.logger.warn(fallbackErr.message) - suggestions = [] - } + } catch (err) { + WIKI.logger.warn(`Search Engine Suggestion Error (pg_trgm extension may be missing): ${err.message}`) } } return {