From 243840c5eba4e6190ad8e0ea6cb080f7f2ea687e Mon Sep 17 00:00:00 2001 From: Artem S Vybornov Date: Mon, 16 Dec 2019 01:52:42 +0300 Subject: [PATCH] fix: postgres engine to query using configured locale (#1269) * fix: Postgres Engine to query using right locale * fix: postgres search dictLanguage parameter binding --- server/modules/search/postgres/engine.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/modules/search/postgres/engine.js b/server/modules/search/postgres/engine.js index 58e3d198..05dc7b18 100644 --- a/server/modules/search/postgres/engine.js +++ b/server/modules/search/postgres/engine.js @@ -62,10 +62,10 @@ module.exports = { let suggestions = [] const results = await WIKI.models.knex.raw(` SELECT id, path, locale, title, description - FROM "pagesVector", to_tsquery(?) query + FROM "pagesVector", to_tsquery(?,?) query WHERE query @@ "tokens" ORDER BY ts_rank(tokens, query) DESC - `, [tsquery(q)]) + `, [this.config.dictLanguage, tsquery(q)]) if (results.rows.length < 5) { 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)