fix: postgres engine to query using configured locale (#1269)
* fix: Postgres Engine to query using right locale * fix: postgres search dictLanguage parameter binding
This commit is contained in:
parent
8d735c2cc7
commit
243840c5eb
@ -62,10 +62,10 @@ module.exports = {
|
|||||||
let suggestions = []
|
let suggestions = []
|
||||||
const results = await WIKI.models.knex.raw(`
|
const results = await WIKI.models.knex.raw(`
|
||||||
SELECT id, path, locale, title, description
|
SELECT id, path, locale, title, description
|
||||||
FROM "pagesVector", to_tsquery(?) query
|
FROM "pagesVector", to_tsquery(?,?) query
|
||||||
WHERE query @@ "tokens"
|
WHERE query @@ "tokens"
|
||||||
ORDER BY ts_rank(tokens, query) DESC
|
ORDER BY ts_rank(tokens, query) DESC
|
||||||
`, [tsquery(q)])
|
`, [this.config.dictLanguage, tsquery(q)])
|
||||||
if (results.rows.length < 5) {
|
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])
|
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)
|
suggestions = suggestResults.rows.map(r => r.word)
|
||||||
|
Loading…
Reference in New Issue
Block a user