@vegan-friendly/strapi-plugin-elasticsearch 0.1.0-alpha.1 → 0.1.0-alpha.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/dist/admin/src/components/Initializer/index.d.ts +15 -0
- package/dist/admin/src/components/Initializer/index.js +25 -0
- package/dist/admin/src/components/PluginIcon/index.d.ts +8 -0
- package/dist/admin/src/components/PluginIcon/index.js +14 -0
- package/dist/admin/src/components/SubNavigation/index.d.ts +4 -0
- package/dist/admin/src/components/SubNavigation/index.js +40 -0
- package/dist/admin/src/index.d.ts +8 -0
- package/dist/admin/src/index.js +92 -0
- package/dist/admin/src/pages/App/index.d.ts +9 -0
- package/dist/admin/src/pages/App/index.js +29 -0
- package/dist/admin/src/pages/ConfigureCollection/index.d.ts +3 -0
- package/dist/admin/src/pages/ConfigureCollection/index.js +193 -0
- package/dist/admin/src/pages/ConfigureCollectionList/index.d.ts +3 -0
- package/dist/admin/src/pages/ConfigureCollectionList/index.js +228 -0
- package/dist/admin/src/pages/Homepage/index.d.ts +3 -0
- package/dist/admin/src/pages/Homepage/index.js +155 -0
- package/dist/admin/src/pages/ViewIndexingRunLog/index.d.ts +3 -0
- package/dist/admin/src/pages/ViewIndexingRunLog/index.js +125 -0
- package/dist/admin/src/pluginId.d.ts +2 -0
- package/dist/admin/src/pluginId.js +8 -0
- package/dist/admin/src/utils/apiUrls.d.ts +10 -0
- package/dist/admin/src/utils/apiUrls.js +20 -0
- package/dist/admin/src/utils/axiosInstance.d.ts +5 -0
- package/dist/admin/src/utils/axiosInstance.js +33 -0
- package/dist/admin/src/utils/getTrad.d.ts +2 -0
- package/dist/admin/src/utils/getTrad.js +8 -0
- package/dist/server/bootstrap.js +125 -0
- package/dist/server/config/index.d.ts +0 -0
- package/dist/server/config/index.js +5 -0
- package/dist/server/content-types/index.d.ts +2 -0
- package/{server → dist/server}/content-types/index.js +7 -9
- package/dist/server/content-types/indexing-logs.d.ts +0 -0
- package/dist/server/content-types/indexing-logs.js +35 -0
- package/dist/server/content-types/name-prefix.d.ts +0 -0
- package/dist/server/content-types/name-prefix.js +1 -0
- package/dist/server/content-types/tasks.d.ts +0 -0
- package/dist/server/content-types/tasks.js +52 -0
- package/dist/server/controllers/configure-indexing.d.ts +0 -0
- package/dist/server/controllers/configure-indexing.js +58 -0
- package/dist/server/controllers/index.d.ts +5 -0
- package/{server → dist/server}/controllers/index.js +13 -15
- package/dist/server/controllers/log-indexing.d.ts +0 -0
- package/{server → dist/server}/controllers/log-indexing.js +10 -11
- package/dist/server/controllers/perform-indexing.d.ts +0 -0
- package/{server → dist/server}/controllers/perform-indexing.js +22 -28
- package/dist/server/controllers/perform-search.d.ts +1 -0
- package/dist/server/controllers/perform-search.js +29 -0
- package/dist/server/controllers/setup-info.d.ts +0 -0
- package/{server → dist/server}/controllers/setup-info.js +10 -14
- package/dist/server/destroy.d.ts +0 -0
- package/{server → dist/server}/destroy.js +4 -5
- package/dist/server/index.d.ts +10 -0
- package/{server → dist/server}/index.js +23 -25
- package/dist/server/middlewares/index.d.ts +0 -0
- package/{server → dist/server}/middlewares/index.js +2 -3
- package/dist/server/policies/index.d.ts +0 -0
- package/{server → dist/server}/policies/index.js +2 -3
- package/dist/server/register.d.ts +0 -0
- package/{server → dist/server}/register.js +4 -5
- package/dist/server/routes/configure-indexing.d.ts +0 -0
- package/dist/server/routes/configure-indexing.js +43 -0
- package/dist/server/routes/index.d.ts +5 -0
- package/{server → dist/server}/routes/index.js +13 -13
- package/dist/server/routes/perform-indexing.d.ts +0 -0
- package/dist/server/routes/perform-indexing.js +25 -0
- package/dist/server/routes/perform-search.d.ts +0 -0
- package/dist/server/routes/perform-search.js +15 -0
- package/dist/server/routes/run-log.d.ts +0 -0
- package/dist/server/routes/run-log.js +13 -0
- package/dist/server/routes/setup-info.d.ts +0 -0
- package/dist/server/routes/setup-info.js +13 -0
- package/dist/server/services/configure-indexing.d.ts +24 -0
- package/dist/server/services/configure-indexing.js +161 -0
- package/dist/server/services/es-interface.d.ts +4 -0
- package/dist/server/services/es-interface.js +161 -0
- package/dist/server/services/helper.d.ts +34 -0
- package/{server → dist/server}/services/helper.js +269 -305
- package/dist/server/services/index.d.ts +7 -0
- package/{server → dist/server}/services/index.js +17 -21
- package/dist/server/services/log-indexing.d.ts +0 -0
- package/{server → dist/server}/services/log-indexing.js +27 -26
- package/dist/server/services/perform-indexing.d.ts +0 -0
- package/{server → dist/server}/services/perform-indexing.js +147 -173
- package/dist/server/services/schedule-indexing.d.ts +0 -0
- package/{server → dist/server}/services/schedule-indexing.js +61 -65
- package/dist/server/services/transform-content.d.ts +2 -0
- package/{server → dist/server}/services/transform-content.js +21 -22
- package/dist/strapi-admin.d.ts +0 -0
- package/{strapi-admin.js → dist/strapi-admin.js} +2 -3
- package/dist/strapi-server.d.ts +0 -0
- package/{strapi-server.js → dist/strapi-server.js} +2 -3
- package/package.json +24 -3
- package/.prettierrc +0 -7
- package/.vscode/settings.json +0 -24
- package/admin/src/components/Initializer/index.js +0 -26
- package/admin/src/components/PluginIcon/index.js +0 -12
- package/admin/src/components/SubNavigation/index.js +0 -48
- package/admin/src/index.js +0 -63
- package/admin/src/pages/App/index.js +0 -29
- package/admin/src/pages/ConfigureCollection/index.js +0 -225
- package/admin/src/pages/ConfigureCollectionList/index.js +0 -266
- package/admin/src/pages/Homepage/index.js +0 -168
- package/admin/src/pages/ViewIndexingRunLog/index.js +0 -124
- package/admin/src/pluginId.js +0 -5
- package/admin/src/translations/en.json +0 -1
- package/admin/src/translations/fr.json +0 -1
- package/admin/src/utils/apiUrls.js +0 -14
- package/admin/src/utils/axiosInstance.js +0 -40
- package/admin/src/utils/getTrad.js +0 -5
- package/server/bootstrap.js +0 -142
- package/server/config/index.js +0 -6
- package/server/content-types/indexing-logs.js +0 -35
- package/server/content-types/tasks.js +0 -52
- package/server/controllers/configure-indexing.js +0 -66
- package/server/controllers/perform-search.js +0 -31
- package/server/routes/configure-indexing.js +0 -42
- package/server/routes/perform-indexing.js +0 -24
- package/server/routes/perform-search.js +0 -14
- package/server/routes/run-log.js +0 -12
- package/server/routes/setup-info.js +0 -12
- package/server/services/configure-indexing.js +0 -184
- package/server/services/es-interface.js +0 -187
- package/server/services/virtual-collections-registry.js +0 -346
- /package/{server/content-types/name-prefix.js → dist/server/bootstrap.d.ts} +0 -0
@@ -0,0 +1,125 @@
|
|
1
|
+
'use strict';
|
2
|
+
console.log('strapi-plugin-elasticsearch : 00 Initializing strapi-plugin-elasticsearch plugin.');
|
3
|
+
module.exports = async ({ strapi }) => {
|
4
|
+
const pluginConfig = await strapi.config.get('plugin.elasticsearch');
|
5
|
+
const configureIndexingService = strapi.plugins['elasticsearch'].services.configureIndexing;
|
6
|
+
const scheduleIndexingService = strapi.plugins['elasticsearch'].services.scheduleIndexing;
|
7
|
+
const esInterface = strapi.plugins['elasticsearch'].services.esInterface;
|
8
|
+
const indexer = strapi.plugins['elasticsearch'].services.indexer;
|
9
|
+
const helper = strapi.plugins['elasticsearch'].services.helper;
|
10
|
+
try {
|
11
|
+
console.log('strapi-plugin-elasticsearch 1: Initializing strapi-plugin-elasticsearch plugin.');
|
12
|
+
await configureIndexingService.initializeStrapiElasticsearch();
|
13
|
+
if (!Object.keys(pluginConfig).includes('indexingCronSchedule'))
|
14
|
+
console.warn('The plugin strapi-plugin-elasticsearch is enabled but the indexingCronSchedule is not configured.');
|
15
|
+
else if (!Object.keys(pluginConfig).includes('searchConnector'))
|
16
|
+
console.warn('The plugin strapi-plugin-elasticsearch is enabled but the searchConnector is not configured.');
|
17
|
+
else {
|
18
|
+
const connector = pluginConfig['searchConnector'];
|
19
|
+
await esInterface.initializeSearchEngine({
|
20
|
+
host: connector.host,
|
21
|
+
uname: connector.username,
|
22
|
+
password: connector.password,
|
23
|
+
cert: connector.certificate,
|
24
|
+
});
|
25
|
+
strapi.cron.add({
|
26
|
+
elasticsearchIndexing: {
|
27
|
+
task: async ({ strapi }) => {
|
28
|
+
await indexer.indexPendingData();
|
29
|
+
},
|
30
|
+
options: {
|
31
|
+
rule: pluginConfig['indexingCronSchedule'],
|
32
|
+
},
|
33
|
+
},
|
34
|
+
});
|
35
|
+
if (await esInterface.checkESConnection()) {
|
36
|
+
//Attach the alias to the current index:
|
37
|
+
const idxName = await helper.getCurrentIndexName();
|
38
|
+
await esInterface.attachAliasToIndex(idxName);
|
39
|
+
}
|
40
|
+
}
|
41
|
+
strapi.db.lifecycles.subscribe(async (event) => {
|
42
|
+
if (event.action === 'afterCreate' || event.action === 'afterUpdate') {
|
43
|
+
if (strapi.elasticsearch.collections.includes(event.model.uid)) {
|
44
|
+
//collection without draft-publish
|
45
|
+
if (typeof event.model.attributes.publishedAt === 'undefined') {
|
46
|
+
await scheduleIndexingService.addItemToIndex({
|
47
|
+
collectionUid: event.model.uid,
|
48
|
+
recordId: event.result.id,
|
49
|
+
});
|
50
|
+
}
|
51
|
+
else if (event.model.attributes.publishedAt) {
|
52
|
+
if (event.result.publishedAt) {
|
53
|
+
await scheduleIndexingService.addItemToIndex({
|
54
|
+
collectionUid: event.model.uid,
|
55
|
+
recordId: event.result.id,
|
56
|
+
});
|
57
|
+
}
|
58
|
+
else {
|
59
|
+
//unpublish
|
60
|
+
await scheduleIndexingService.removeItemFromIndex({
|
61
|
+
collectionUid: event.model.uid,
|
62
|
+
recordId: event.result.id,
|
63
|
+
});
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
//bulk publish-unpublish from list view
|
69
|
+
if (event.action === 'afterCreateMany' || event.action === 'afterUpdateMany') {
|
70
|
+
if (strapi.elasticsearch.collections.includes(event.model.uid)) {
|
71
|
+
if (Object.keys(event.params.where.id).includes('$in')) {
|
72
|
+
const updatedItemIds = event.params.where.id['$in'];
|
73
|
+
//bulk unpublish
|
74
|
+
if (typeof event.params.data.publishedAt === 'undefined' ||
|
75
|
+
event.params.data.publishedAt === null) {
|
76
|
+
for (let k = 0; k < updatedItemIds.length; k++) {
|
77
|
+
await scheduleIndexingService.removeItemFromIndex({
|
78
|
+
collectionUid: event.model.uid,
|
79
|
+
recordId: updatedItemIds[k],
|
80
|
+
});
|
81
|
+
}
|
82
|
+
}
|
83
|
+
else {
|
84
|
+
for (let k = 0; k < updatedItemIds.length; k++) {
|
85
|
+
await scheduleIndexingService.addItemToIndex({
|
86
|
+
collectionUid: event.model.uid,
|
87
|
+
recordId: updatedItemIds[k],
|
88
|
+
});
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
if (event.action === 'afterDelete') {
|
95
|
+
if (strapi.elasticsearch.collections.includes(event.model.uid)) {
|
96
|
+
await scheduleIndexingService.removeItemFromIndex({
|
97
|
+
collectionUid: event.model.uid,
|
98
|
+
recordId: event.result.id,
|
99
|
+
});
|
100
|
+
}
|
101
|
+
}
|
102
|
+
if (event.action === 'afterDeleteMany') {
|
103
|
+
if (strapi.elasticsearch.collections.includes(event.model.uid)) {
|
104
|
+
if (Object.keys(event.params.where).includes('$and') &&
|
105
|
+
Array.isArray(event.params.where['$and']) &&
|
106
|
+
Object.keys(event.params.where['$and'][0]).includes('id') &&
|
107
|
+
Object.keys(event.params.where['$and'][0]['id']).includes('$in')) {
|
108
|
+
const deletedItemIds = event.params.where['$and'][0]['id']['$in'];
|
109
|
+
for (let k = 0; k < deletedItemIds.length; k++) {
|
110
|
+
await scheduleIndexingService.removeItemFromIndex({
|
111
|
+
collectionUid: event.model.uid,
|
112
|
+
recordId: deletedItemIds[k],
|
113
|
+
});
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}
|
118
|
+
});
|
119
|
+
configureIndexingService.markInitialized();
|
120
|
+
}
|
121
|
+
catch (err) {
|
122
|
+
console.error('An error was encountered while initializing the strapi-plugin-elasticsearch plugin.');
|
123
|
+
console.error(err);
|
124
|
+
}
|
125
|
+
};
|
File without changes
|
@@ -1,9 +1,7 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
'indexing-log' : {schema: indexingLog}
|
9
|
-
};
|
1
|
+
'use strict';
|
2
|
+
const task = require('./tasks');
|
3
|
+
const indexingLog = require('./indexing-logs');
|
4
|
+
module.exports = {
|
5
|
+
'task': { schema: task },
|
6
|
+
'indexing-log': { schema: indexingLog }
|
7
|
+
};
|
File without changes
|
@@ -0,0 +1,35 @@
|
|
1
|
+
"use strict";
|
2
|
+
module.exports = {
|
3
|
+
"kind": "collectionType",
|
4
|
+
"collectionName": "indexing-log",
|
5
|
+
"info": {
|
6
|
+
"singularName": "indexing-log",
|
7
|
+
"pluralName": "indexing-logs",
|
8
|
+
"displayName": "Indexing Logs",
|
9
|
+
"description": "Logged runs of the indexing cron job"
|
10
|
+
},
|
11
|
+
"options": {
|
12
|
+
"draftAndPublish": false
|
13
|
+
},
|
14
|
+
"pluginOptions": {
|
15
|
+
'content-manager': {
|
16
|
+
visible: false,
|
17
|
+
},
|
18
|
+
'content-type-builder': {
|
19
|
+
visible: false,
|
20
|
+
}
|
21
|
+
},
|
22
|
+
"attributes": {
|
23
|
+
"status": {
|
24
|
+
"type": "enumeration",
|
25
|
+
"enum": [
|
26
|
+
"pass",
|
27
|
+
"fail"
|
28
|
+
],
|
29
|
+
"required": true
|
30
|
+
},
|
31
|
+
"details": {
|
32
|
+
"type": "text"
|
33
|
+
}
|
34
|
+
}
|
35
|
+
};
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";
|
File without changes
|
@@ -0,0 +1,52 @@
|
|
1
|
+
"use strict";
|
2
|
+
module.exports = {
|
3
|
+
"kind": "collectionType",
|
4
|
+
"collectionName": "task",
|
5
|
+
"info": {
|
6
|
+
"singularName": "task",
|
7
|
+
"pluralName": "tasks",
|
8
|
+
"displayName": "Task",
|
9
|
+
"description": "Search indexing tasks"
|
10
|
+
},
|
11
|
+
"options": {
|
12
|
+
"draftAndPublish": false
|
13
|
+
},
|
14
|
+
"pluginOptions": {
|
15
|
+
'content-manager': {
|
16
|
+
visible: false,
|
17
|
+
},
|
18
|
+
'content-type-builder': {
|
19
|
+
visible: false,
|
20
|
+
}
|
21
|
+
},
|
22
|
+
"attributes": {
|
23
|
+
"collection_name": {
|
24
|
+
"type": "string",
|
25
|
+
"required": true
|
26
|
+
},
|
27
|
+
"item_id": {
|
28
|
+
"type": "integer"
|
29
|
+
},
|
30
|
+
"indexing_status": {
|
31
|
+
"type": "enumeration",
|
32
|
+
"enum": [
|
33
|
+
"to-be-done",
|
34
|
+
"done"
|
35
|
+
],
|
36
|
+
"required": true,
|
37
|
+
"default": "to-be-done"
|
38
|
+
},
|
39
|
+
"full_site_indexing": {
|
40
|
+
"type": "boolean"
|
41
|
+
},
|
42
|
+
"indexing_type": {
|
43
|
+
"type": "enumeration",
|
44
|
+
"enum": [
|
45
|
+
"add-to-index",
|
46
|
+
"remove-from-index"
|
47
|
+
],
|
48
|
+
"default": "add-to-index",
|
49
|
+
"required": true
|
50
|
+
}
|
51
|
+
}
|
52
|
+
};
|
File without changes
|
@@ -0,0 +1,58 @@
|
|
1
|
+
'use strict';
|
2
|
+
module.exports = ({ strapi }) => {
|
3
|
+
const configureIndexingService = strapi.plugins['elasticsearch'].services.configureIndexing;
|
4
|
+
const getContentConfig = async (ctx) => {
|
5
|
+
return configureIndexingService.getContentConfig();
|
6
|
+
};
|
7
|
+
const saveCollectionConfig = async (ctx) => {
|
8
|
+
const { body } = ctx.request;
|
9
|
+
try {
|
10
|
+
const updatedConfig = await configureIndexingService.setContentConfig({ collection: ctx.params.collectionname, config: body.data });
|
11
|
+
return updatedConfig;
|
12
|
+
}
|
13
|
+
catch (err) {
|
14
|
+
ctx.throw(500, err);
|
15
|
+
}
|
16
|
+
};
|
17
|
+
const importContentConfig = async (ctx) => {
|
18
|
+
const { body } = ctx.request;
|
19
|
+
try {
|
20
|
+
if (body['data']) {
|
21
|
+
const updatedConfig = await configureIndexingService.importContentConfig({ config: body['data'] });
|
22
|
+
return updatedConfig;
|
23
|
+
}
|
24
|
+
else
|
25
|
+
ctx.throw(400, 'Invalid parameters');
|
26
|
+
}
|
27
|
+
catch (err) {
|
28
|
+
ctx.throw(500, err);
|
29
|
+
}
|
30
|
+
};
|
31
|
+
const exportContentConfig = async (ctx) => {
|
32
|
+
return configureIndexingService.getContentConfig();
|
33
|
+
};
|
34
|
+
const setContentConfig = async (ctx) => {
|
35
|
+
const { body } = ctx.request;
|
36
|
+
try {
|
37
|
+
const updatedConfig = await configureIndexingService.setContentConfig({ config: body });
|
38
|
+
return updatedConfig;
|
39
|
+
}
|
40
|
+
catch (err) {
|
41
|
+
ctx.throw(500, err);
|
42
|
+
}
|
43
|
+
};
|
44
|
+
const getCollectionConfig = async (ctx) => {
|
45
|
+
if (ctx.params.collectionname)
|
46
|
+
return configureIndexingService.getCollectionConfig({ collectionName: ctx.params.collectionname });
|
47
|
+
else
|
48
|
+
return null;
|
49
|
+
};
|
50
|
+
return {
|
51
|
+
getContentConfig,
|
52
|
+
setContentConfig,
|
53
|
+
getCollectionConfig,
|
54
|
+
saveCollectionConfig,
|
55
|
+
exportContentConfig,
|
56
|
+
importContentConfig
|
57
|
+
};
|
58
|
+
};
|
@@ -1,15 +1,13 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const
|
4
|
-
const
|
5
|
-
const
|
6
|
-
const
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
performIndexing
|
15
|
-
};
|
1
|
+
'use strict';
|
2
|
+
const configureIndexing = require('./configure-indexing');
|
3
|
+
const performSearch = require('./perform-search');
|
4
|
+
const logIndexing = require('./log-indexing');
|
5
|
+
const setupInfo = require('./setup-info');
|
6
|
+
const performIndexing = require('./perform-indexing');
|
7
|
+
module.exports = {
|
8
|
+
configureIndexing,
|
9
|
+
performSearch,
|
10
|
+
logIndexing,
|
11
|
+
setupInfo,
|
12
|
+
performIndexing
|
13
|
+
};
|
File without changes
|
@@ -1,11 +1,10 @@
|
|
1
|
-
|
2
|
-
module.exports = ({ strapi }) => {
|
3
|
-
const logIndexingService = strapi.plugins['elasticsearch'].services.logIndexing;
|
4
|
-
const fetchRecentRunsLog = async (ctx) => {
|
5
|
-
return await logIndexingService.fetchIndexingLogs();
|
6
|
-
}
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
}
|
1
|
+
"use strict";
|
2
|
+
module.exports = ({ strapi }) => {
|
3
|
+
const logIndexingService = strapi.plugins['elasticsearch'].services.logIndexing;
|
4
|
+
const fetchRecentRunsLog = async (ctx) => {
|
5
|
+
return await logIndexingService.fetchIndexingLogs();
|
6
|
+
};
|
7
|
+
return {
|
8
|
+
fetchRecentRunsLog
|
9
|
+
};
|
10
|
+
};
|
File without changes
|
@@ -1,28 +1,22 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
const
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
}
|
22
|
-
|
23
|
-
return {
|
24
|
-
rebuildIndex,
|
25
|
-
indexCollection,
|
26
|
-
triggerIndexingTask
|
27
|
-
};
|
28
|
-
}
|
1
|
+
'use strict';
|
2
|
+
module.exports = ({ strapi }) => {
|
3
|
+
const indexer = strapi.plugins['elasticsearch'].services.indexer;
|
4
|
+
const scheduleIndexingService = strapi.plugins['elasticsearch'].services.scheduleIndexing;
|
5
|
+
const rebuildIndex = async (ctx) => {
|
6
|
+
return await indexer.rebuildIndex();
|
7
|
+
};
|
8
|
+
const indexCollection = async (ctx) => {
|
9
|
+
if (ctx.params.collectionname)
|
10
|
+
return await scheduleIndexingService.addCollectionToIndex({ collectionUid: ctx.params.collectionname });
|
11
|
+
else
|
12
|
+
return null;
|
13
|
+
};
|
14
|
+
const triggerIndexingTask = async (ctx) => {
|
15
|
+
return await indexer.indexPendingData();
|
16
|
+
};
|
17
|
+
return {
|
18
|
+
rebuildIndex,
|
19
|
+
indexCollection,
|
20
|
+
triggerIndexingTask
|
21
|
+
};
|
22
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
declare const qs: any;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
'use strict';
|
2
|
+
const qs = require('qs');
|
3
|
+
module.exports = {
|
4
|
+
search: async (ctx) => {
|
5
|
+
var _a;
|
6
|
+
try {
|
7
|
+
const esInterface = strapi.plugins['elasticsearch'].services.esInterface;
|
8
|
+
if (ctx.query.query) {
|
9
|
+
const query = qs.parse(ctx.query.query);
|
10
|
+
const resp = await esInterface.searchData(query);
|
11
|
+
if ((_a = resp === null || resp === void 0 ? void 0 : resp.hits) === null || _a === void 0 ? void 0 : _a.hits) {
|
12
|
+
const filteredData = resp.hits.hits.filter(dt => dt._source !== null);
|
13
|
+
const filteredMatches = filteredData.map((dt) => dt['_source']);
|
14
|
+
ctx.body = filteredMatches;
|
15
|
+
}
|
16
|
+
else
|
17
|
+
ctx.body = {};
|
18
|
+
}
|
19
|
+
else
|
20
|
+
ctx.body = {};
|
21
|
+
}
|
22
|
+
catch (err) {
|
23
|
+
ctx.response.status = 500;
|
24
|
+
ctx.body = "An error was encountered while processing the search request.";
|
25
|
+
console.log('An error was encountered while processing the search request.');
|
26
|
+
console.log(err);
|
27
|
+
}
|
28
|
+
}
|
29
|
+
};
|
File without changes
|
@@ -1,14 +1,10 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
}
|
10
|
-
|
11
|
-
return {
|
12
|
-
getElasticsearchInfo,
|
13
|
-
};
|
14
|
-
}
|
1
|
+
'use strict';
|
2
|
+
module.exports = ({ strapi }) => {
|
3
|
+
const helperService = strapi.plugins['elasticsearch'].services.helper;
|
4
|
+
const getElasticsearchInfo = async (ctx) => {
|
5
|
+
return helperService.getElasticsearchInfo();
|
6
|
+
};
|
7
|
+
return {
|
8
|
+
getElasticsearchInfo,
|
9
|
+
};
|
10
|
+
};
|
File without changes
|
@@ -1,5 +1,4 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
};
|
1
|
+
'use strict';
|
2
|
+
module.exports = ({ strapi }) => {
|
3
|
+
// destroy phase
|
4
|
+
};
|
@@ -0,0 +1,10 @@
|
|
1
|
+
declare const register: any;
|
2
|
+
declare const bootstrap: any;
|
3
|
+
declare const destroy: any;
|
4
|
+
declare const config: any;
|
5
|
+
declare const contentTypes: any;
|
6
|
+
declare const controllers: any;
|
7
|
+
declare const routes: any;
|
8
|
+
declare const middlewares: any;
|
9
|
+
declare const policies: any;
|
10
|
+
declare const services: any;
|
@@ -1,25 +1,23 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const
|
4
|
-
const
|
5
|
-
const
|
6
|
-
const
|
7
|
-
const
|
8
|
-
const
|
9
|
-
const
|
10
|
-
const
|
11
|
-
const
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
middlewares,
|
25
|
-
};
|
1
|
+
'use strict';
|
2
|
+
const register = require('./register');
|
3
|
+
const bootstrap = require('./bootstrap');
|
4
|
+
const destroy = require('./destroy');
|
5
|
+
const config = require('./config');
|
6
|
+
const contentTypes = require('./content-types');
|
7
|
+
const controllers = require('./controllers');
|
8
|
+
const routes = require('./routes');
|
9
|
+
const middlewares = require('./middlewares');
|
10
|
+
const policies = require('./policies');
|
11
|
+
const services = require('./services');
|
12
|
+
module.exports = {
|
13
|
+
register,
|
14
|
+
bootstrap,
|
15
|
+
destroy,
|
16
|
+
config,
|
17
|
+
controllers,
|
18
|
+
routes,
|
19
|
+
services,
|
20
|
+
contentTypes,
|
21
|
+
policies,
|
22
|
+
middlewares,
|
23
|
+
};
|
File without changes
|
@@ -1,3 +1,2 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
module.exports = {};
|
1
|
+
'use strict';
|
2
|
+
module.exports = {};
|
File without changes
|
@@ -1,3 +1,2 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
module.exports = {};
|
1
|
+
'use strict';
|
2
|
+
module.exports = {};
|
File without changes
|
@@ -1,5 +1,4 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
};
|
1
|
+
'use strict';
|
2
|
+
module.exports = ({ strapi }) => {
|
3
|
+
// register phase
|
4
|
+
};
|
File without changes
|
@@ -0,0 +1,43 @@
|
|
1
|
+
"use strict";
|
2
|
+
module.exports = {
|
3
|
+
// accessible only from admin UI
|
4
|
+
type: 'admin',
|
5
|
+
routes: [
|
6
|
+
{
|
7
|
+
method: 'GET',
|
8
|
+
path: '/content-config',
|
9
|
+
handler: 'configureIndexing.getContentConfig',
|
10
|
+
config: { policies: [] },
|
11
|
+
},
|
12
|
+
{
|
13
|
+
method: 'GET',
|
14
|
+
path: '/collection-config/:collectionname',
|
15
|
+
handler: 'configureIndexing.getCollectionConfig',
|
16
|
+
config: { policies: [] },
|
17
|
+
},
|
18
|
+
{
|
19
|
+
method: 'POST',
|
20
|
+
path: '/collection-config/:collectionname',
|
21
|
+
handler: 'configureIndexing.saveCollectionConfig',
|
22
|
+
config: { policies: [] },
|
23
|
+
},
|
24
|
+
{
|
25
|
+
method: 'POST',
|
26
|
+
path: '/content-config',
|
27
|
+
handler: 'configureIndexing.setContentConfig',
|
28
|
+
config: { policies: [] },
|
29
|
+
},
|
30
|
+
{
|
31
|
+
method: 'GET',
|
32
|
+
path: '/export-content-config',
|
33
|
+
handler: 'configureIndexing.exportContentConfig',
|
34
|
+
config: { policies: [] },
|
35
|
+
},
|
36
|
+
{
|
37
|
+
method: 'POST',
|
38
|
+
path: '/import-content-config',
|
39
|
+
handler: 'configureIndexing.importContentConfig',
|
40
|
+
config: { policies: [] },
|
41
|
+
},
|
42
|
+
],
|
43
|
+
};
|