nodebb-plugin-dbsearch 5.0.0 → 5.0.4
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 +1 -1
- package/lib/redis.js +5 -3
- package/package.json +2 -2
- package/upgrades/dbsearch_change_mongodb_schema.js +11 -32
package/lib/postgres.js
CHANGED
|
@@ -40,7 +40,7 @@ exports.createIndices = async function (language) {
|
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
exports.
|
|
43
|
+
exports.changeIndexLanguage = async function (language) {
|
|
44
44
|
searchLanguage = language;
|
|
45
45
|
pubsub.publish('dbsearch-language-changed', language);
|
|
46
46
|
await db.pool.query('DROP INDEX "idx__searchtopic__content"');
|
package/lib/redis.js
CHANGED
|
@@ -26,7 +26,7 @@ exports.searchIndex = async function (key, data, ids) {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
exports.search = async function (key, data, limit) {
|
|
29
|
-
const queryMethod = key === 'post' ? db.postSearch
|
|
29
|
+
const queryMethod = key === 'post' ? db.postSearch : db.topicSearch;
|
|
30
30
|
|
|
31
31
|
const query = {
|
|
32
32
|
matchWords: data.matchWords,
|
|
@@ -37,7 +37,7 @@ exports.search = async function (key, data, limit) {
|
|
|
37
37
|
},
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
return await queryMethod(query, 0, limit - 1);
|
|
40
|
+
return await queryMethod.query(query, 0, limit - 1);
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
exports.searchRemove = async function (key, ids) {
|
|
@@ -46,5 +46,7 @@ exports.searchRemove = async function (key, ids) {
|
|
|
46
46
|
}
|
|
47
47
|
var method = key === 'post' ? db.postSearch : db.topicSearch;
|
|
48
48
|
|
|
49
|
-
await async.eachLimit(ids, 500,
|
|
49
|
+
await async.eachLimit(ids, 500, async function (ids) {
|
|
50
|
+
await method.remove(ids);
|
|
51
|
+
});
|
|
50
52
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodebb-plugin-dbsearch",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.4",
|
|
4
4
|
"description": "A Plugin that lets users search posts and topics",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"author": "Baris Usakli <baris@designcreateplay.com>",
|
|
19
19
|
"license": "BSD-2-Clause",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"lodash": "4.17.
|
|
21
|
+
"lodash": "4.17.21",
|
|
22
22
|
"redisearch": "^1.0.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
@@ -1,49 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
const async = require.main.require('async');
|
|
5
4
|
const winston = require.main.require('winston');
|
|
6
5
|
const db = module.parent.require('./database');
|
|
7
6
|
|
|
8
7
|
module.exports = {
|
|
9
8
|
name: 'Changing dbsearch mongodb search schema to use _id',
|
|
10
9
|
timestamp: Date.UTC(2018, 10, 26),
|
|
11
|
-
method: function (
|
|
10
|
+
method: async function () {
|
|
12
11
|
const nconf = require.main.require('nconf');
|
|
13
12
|
const isMongo = nconf.get('database') === 'mongo';
|
|
14
13
|
if (!isMongo) {
|
|
15
|
-
return
|
|
14
|
+
return;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
const plugin = require('../lib/dbsearch');
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
function (next) {
|
|
29
|
-
client.collection('searchtopic').dropIndex({ id: 1 }, function (err) {
|
|
30
|
-
if (err) {
|
|
31
|
-
winston.error(err);
|
|
32
|
-
}
|
|
33
|
-
next();
|
|
34
|
-
});
|
|
35
|
-
},
|
|
36
|
-
function (next) {
|
|
37
|
-
client.collection('searchpost').dropIndex({ id: 1 }, function (err) {
|
|
38
|
-
if (err) {
|
|
39
|
-
winston.error(err);
|
|
40
|
-
}
|
|
41
|
-
next();
|
|
42
|
-
});
|
|
43
|
-
},
|
|
44
|
-
async function () {
|
|
45
|
-
await plugin.reindex();
|
|
46
|
-
},
|
|
47
|
-
], callback);
|
|
18
|
+
await db.client.collection('searchtopic').deleteMany({});
|
|
19
|
+
await db.client.collection('searchpost').deleteMany({});
|
|
20
|
+
try {
|
|
21
|
+
await db.client.collection('searchtopic').dropIndex({ id: 1 });
|
|
22
|
+
await db.client.collection('searchpost').dropIndex({ id: 1 });
|
|
23
|
+
} catch (err) {
|
|
24
|
+
winston.error(err.stack);
|
|
25
|
+
}
|
|
26
|
+
await plugin.reindex();
|
|
48
27
|
},
|
|
49
28
|
};
|