nodebb-plugin-dbsearch 6.2.1 → 6.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/postgres.js +2 -2
- package/package.json +1 -1
package/lib/postgres.js
CHANGED
|
@@ -130,7 +130,7 @@ exports.chat.index = async (data, ids) => {
|
|
|
130
130
|
try {
|
|
131
131
|
await db.pool.query({
|
|
132
132
|
name: `dbsearch-searchIndex-chat`,
|
|
133
|
-
text: `INSERT INTO "searchchat" SELECT d."id", d."data"->>'content' "content", (d."data"->>'uid')::bigint "uid", (d."data"->>'roomId')::bigint "
|
|
133
|
+
text: `INSERT INTO "searchchat" SELECT d."id", d."data"->>'content' "content", (d."data"->>'uid')::bigint "uid", (d."data"->>'roomId')::bigint "rid" FROM UNNEST($1::bigint[], $2::jsonb[]) d("id", "data") ON CONFLICT ("id") DO UPDATE SET "content" = COALESCE(EXCLUDED."content", "searchchat"."content"), "uid" = COALESCE(EXCLUDED."uid", "searchchat"."uid"), "rid" = COALESCE(EXCLUDED."rid", "searchchat"."rid")`,
|
|
134
134
|
values: [ids, data],
|
|
135
135
|
});
|
|
136
136
|
} catch (err) {
|
|
@@ -155,7 +155,7 @@ exports.chat.search = async (data, limit) => {
|
|
|
155
155
|
try {
|
|
156
156
|
const res = await db.pool.query({
|
|
157
157
|
name: `dbsearch-search-chat`,
|
|
158
|
-
text: `SELECT ARRAY(SELECT s."id" FROM "searchchat" s WHERE ($1::text IS NULL OR to_tsvector($5::regconfig, "content") @@ plainto_tsquery($5::regconfig, $1::text)) AND ($2::bigint[] IS NULL OR "uid" = ANY($2::bigint[])) AND ($3::bigint[] IS NULL OR "
|
|
158
|
+
text: `SELECT ARRAY(SELECT s."id" FROM "searchchat" s WHERE ($1::text IS NULL OR to_tsvector($5::regconfig, "content") @@ plainto_tsquery($5::regconfig, $1::text)) AND ($2::bigint[] IS NULL OR "uid" = ANY($2::bigint[])) AND ($3::bigint[] IS NULL OR "rid" = ANY($3::bigint[])) ORDER BY ts_rank_cd(to_tsvector($5::regconfig, "content"), plainto_tsquery($5::regconfig, $1::text)) DESC, s."id" ASC LIMIT $4::integer) r`,
|
|
159
159
|
values: [data.content, data.uid, data.roomId, parseInt(limit, 10), searchLanguage],
|
|
160
160
|
});
|
|
161
161
|
return res.rows[0].r;
|