@vegan-friendly/strapi-plugin-elasticsearch 0.0.11-alpha.6 → 0.1.0-alpha.0
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/.prettierrc +7 -0
- package/.vscode/settings.json +24 -0
- package/README.md +0 -4
- package/admin/src/components/Initializer/index.js +26 -0
- package/admin/src/components/PluginIcon/index.js +12 -0
- package/admin/src/components/SubNavigation/index.js +48 -0
- package/admin/src/index.js +63 -0
- package/admin/src/pages/App/index.js +29 -0
- package/admin/src/pages/ConfigureCollection/index.js +225 -0
- package/admin/src/pages/ConfigureCollectionList/index.js +266 -0
- package/admin/src/pages/Homepage/index.js +168 -0
- package/admin/src/pages/ViewIndexingRunLog/index.js +124 -0
- package/admin/src/pluginId.js +5 -0
- package/admin/src/translations/en.json +1 -0
- package/admin/src/translations/fr.json +1 -0
- package/admin/src/utils/apiUrls.js +14 -0
- package/admin/src/utils/axiosInstance.js +40 -0
- package/admin/src/utils/getTrad.js +5 -0
- package/package.json +40 -80
- package/server/bootstrap.js +142 -0
- package/server/config/index.js +6 -0
- package/server/content-types/index.js +9 -0
- package/server/content-types/indexing-logs.js +35 -0
- package/server/content-types/name-prefix.js +0 -0
- package/server/content-types/tasks.js +52 -0
- package/server/controllers/configure-indexing.js +66 -0
- package/server/controllers/index.js +15 -0
- package/server/controllers/log-indexing.js +11 -0
- package/server/controllers/perform-indexing.js +28 -0
- package/server/controllers/perform-search.js +31 -0
- package/server/controllers/setup-info.js +14 -0
- package/server/destroy.js +5 -0
- package/server/index.js +25 -0
- package/server/middlewares/index.js +3 -0
- package/server/policies/index.js +3 -0
- package/server/register.js +5 -0
- package/server/routes/configure-indexing.js +42 -0
- package/server/routes/index.js +13 -0
- package/server/routes/perform-indexing.js +24 -0
- package/server/routes/perform-search.js +14 -0
- package/server/routes/run-log.js +12 -0
- package/server/routes/setup-info.js +12 -0
- package/server/services/configure-indexing.js +184 -0
- package/server/services/es-interface.js +187 -0
- package/server/services/helper.js +305 -0
- package/server/services/index.js +21 -0
- package/server/services/log-indexing.js +26 -0
- package/server/services/perform-indexing.js +173 -0
- package/server/services/schedule-indexing.js +65 -0
- package/server/services/transform-content.js +22 -0
- package/server/services/virtual-collections-registry.js +445 -0
- package/strapi-admin.js +3 -0
- package/strapi-server.js +3 -0
- package/dist/_chunks/App-Br53NnT1.mjs +0 -17315
- package/dist/_chunks/App-C3jMSu4l.js +0 -17314
- package/dist/_chunks/en-B4KWt_jN.js +0 -4
- package/dist/_chunks/en-Byx4XI2L.mjs +0 -4
- package/dist/_chunks/index-BlmgBQo2.js +0 -71
- package/dist/_chunks/index-CRnRLV0T.mjs +0 -72
- package/dist/admin/index.js +0 -3
- package/dist/admin/index.mjs +0 -4
- package/dist/server/index.js +0 -7330
- package/dist/server/index.mjs +0 -7307
package/package.json
CHANGED
@@ -1,80 +1,40 @@
|
|
1
|
-
{
|
2
|
-
"name": "@vegan-friendly/strapi-plugin-elasticsearch",
|
3
|
-
"
|
4
|
-
"
|
5
|
-
"
|
6
|
-
"
|
7
|
-
|
8
|
-
"
|
9
|
-
"
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
"
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
"
|
26
|
-
"
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
"
|
31
|
-
"
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
"dist"
|
42
|
-
],
|
43
|
-
"scripts": {
|
44
|
-
"build": "strapi-plugin build",
|
45
|
-
"watch": "strapi-plugin watch",
|
46
|
-
"watch:link": "strapi-plugin watch:link",
|
47
|
-
"verify": "strapi-plugin verify"
|
48
|
-
},
|
49
|
-
"dependencies": {
|
50
|
-
"@elastic/elasticsearch": "^8.17.1",
|
51
|
-
"@radix-ui/react-tooltip": "^1.1.8",
|
52
|
-
"@strapi/design-system": "^2.0.0-rc.18",
|
53
|
-
"@strapi/icons": "^2.0.0-rc.18",
|
54
|
-
"markdown-to-txt": "^2.0.1",
|
55
|
-
"react-intl": "^7.1.9"
|
56
|
-
},
|
57
|
-
"devDependencies": {
|
58
|
-
"@strapi/sdk-plugin": "^5.3.2 || ^4.0.0",
|
59
|
-
"@strapi/strapi": "^5.11.3 || ^4.0.0",
|
60
|
-
"prettier": "^3.5.3",
|
61
|
-
"react": "^18.3.1",
|
62
|
-
"react-dom": "^18.3.1",
|
63
|
-
"react-router-dom": "^6.30.0 || ^5",
|
64
|
-
"styled-components": "^6.1.16 || ^5"
|
65
|
-
},
|
66
|
-
"peerDependencies": {
|
67
|
-
"@strapi/sdk-plugin": "^5.3.2 || ^4.0.0",
|
68
|
-
"@strapi/strapi": "^5.11.3 || ^4.0.0",
|
69
|
-
"react": "^18.3.1",
|
70
|
-
"react-dom": "^18.3.1",
|
71
|
-
"react-router-dom": "^6.30.0 || ^5",
|
72
|
-
"styled-components": "^6.1.16 || ^5"
|
73
|
-
},
|
74
|
-
"strapi": {
|
75
|
-
"name": "elasticsearch",
|
76
|
-
"description": "A plugin to enable using Elasticsearch with Strapi CMS.",
|
77
|
-
"kind": "plugin",
|
78
|
-
"displayName": "Strapi <-> Elasticsearch"
|
79
|
-
}
|
80
|
-
}
|
1
|
+
{
|
2
|
+
"name": "@vegan-friendly/strapi-plugin-elasticsearch",
|
3
|
+
"version": "0.1.0-alpha.0",
|
4
|
+
"description": "A Strapi plugin to enable using Elasticsearch with Strapi CMS.",
|
5
|
+
"homepage": "https://github.com/vegan-friendly/strapi-plugin-elasticsearch",
|
6
|
+
"strapi": {
|
7
|
+
"name": "elasticsearch",
|
8
|
+
"description": "A plugin to enable using Elasticsearch with Strapi CMS.",
|
9
|
+
"kind": "plugin",
|
10
|
+
"displayName": "Strapi <-> Elasticsearch"
|
11
|
+
},
|
12
|
+
"repository": {
|
13
|
+
"type": "git",
|
14
|
+
"url": "git://github.com/vegan-friendly/strapi-plugin-elasticsearch.git"
|
15
|
+
},
|
16
|
+
"author": {
|
17
|
+
"name": "Punit Sethi",
|
18
|
+
"email": "punit@tezify.com",
|
19
|
+
"url": "https://punits.dev"
|
20
|
+
},
|
21
|
+
"dependencies": {
|
22
|
+
"@elastic/elasticsearch": "^8.9.0",
|
23
|
+
"markdown-to-txt": "^2.0.1"
|
24
|
+
},
|
25
|
+
"peerDependencies": {
|
26
|
+
"@strapi/strapi": "^4.0.0"
|
27
|
+
},
|
28
|
+
"maintainers": [
|
29
|
+
{
|
30
|
+
"name": "Punit Sethi",
|
31
|
+
"email": "punit@tezify.com",
|
32
|
+
"url": "https://punits.dev"
|
33
|
+
}
|
34
|
+
],
|
35
|
+
"engines": {
|
36
|
+
"node": ">=16.0.0 <=20.x.x",
|
37
|
+
"npm": ">=6.0.0"
|
38
|
+
},
|
39
|
+
"license": "MIT"
|
40
|
+
}
|
@@ -0,0 +1,142 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
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
|
+
{
|
12
|
+
await configureIndexingService.initializeStrapiElasticsearch();
|
13
|
+
|
14
|
+
if (!Object.keys(pluginConfig).includes('indexingCronSchedule'))
|
15
|
+
console.warn("The plugin strapi-plugin-elasticsearch is enabled but the indexingCronSchedule is not configured.");
|
16
|
+
else if (!Object.keys(pluginConfig).includes('searchConnector'))
|
17
|
+
console.warn("The plugin strapi-plugin-elasticsearch is enabled but the searchConnector is not configured.");
|
18
|
+
else
|
19
|
+
{
|
20
|
+
const connector = pluginConfig['searchConnector'];
|
21
|
+
await esInterface.initializeSearchEngine({host : connector.host, uname: connector.username,
|
22
|
+
password: connector.password, cert: connector.certificate});
|
23
|
+
strapi.cron.add({
|
24
|
+
elasticsearchIndexing: {
|
25
|
+
task: async ({ strapi }) => {
|
26
|
+
await indexer.indexPendingData();
|
27
|
+
},
|
28
|
+
options: {
|
29
|
+
rule: pluginConfig['indexingCronSchedule'],
|
30
|
+
},
|
31
|
+
},
|
32
|
+
});
|
33
|
+
|
34
|
+
if (await esInterface.checkESConnection())
|
35
|
+
{
|
36
|
+
//Attach the alias to the current index:
|
37
|
+
const idxName = await helper.getCurrentIndexName();
|
38
|
+
await esInterface.attachAliasToIndex(idxName);
|
39
|
+
}
|
40
|
+
|
41
|
+
}
|
42
|
+
|
43
|
+
strapi.db.lifecycles.subscribe(async (event) => {
|
44
|
+
if (event.action === 'afterCreate' || event.action === 'afterUpdate') {
|
45
|
+
if (strapi.elasticsearch.collections.includes(event.model.uid))
|
46
|
+
{
|
47
|
+
//collection without draft-publish
|
48
|
+
if (typeof event.model.attributes.publishedAt === "undefined")
|
49
|
+
{
|
50
|
+
await scheduleIndexingService.addItemToIndex({
|
51
|
+
collectionUid: event.model.uid,
|
52
|
+
recordId: event.result.id
|
53
|
+
});
|
54
|
+
}
|
55
|
+
else if (event.model.attributes.publishedAt)
|
56
|
+
{
|
57
|
+
if (event.result.publishedAt)
|
58
|
+
{
|
59
|
+
await scheduleIndexingService.addItemToIndex({
|
60
|
+
collectionUid: event.model.uid,
|
61
|
+
recordId: event.result.id
|
62
|
+
});
|
63
|
+
}
|
64
|
+
else
|
65
|
+
{
|
66
|
+
//unpublish
|
67
|
+
await scheduleIndexingService.removeItemFromIndex({
|
68
|
+
collectionUid: event.model.uid,
|
69
|
+
recordId: event.result.id
|
70
|
+
});
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
}
|
75
|
+
//bulk publish-unpublish from list view
|
76
|
+
if (event.action === 'afterCreateMany' || event.action === 'afterUpdateMany') {
|
77
|
+
if (strapi.elasticsearch.collections.includes(event.model.uid))
|
78
|
+
{
|
79
|
+
if (Object.keys(event.params.where.id).includes('$in'))
|
80
|
+
{
|
81
|
+
const updatedItemIds = event.params.where.id['$in']
|
82
|
+
//bulk unpublish
|
83
|
+
if (typeof event.params.data.publishedAt === "undefined" ||
|
84
|
+
event.params.data.publishedAt === null)
|
85
|
+
{
|
86
|
+
for (let k = 0; k< updatedItemIds.length; k++)
|
87
|
+
{
|
88
|
+
await scheduleIndexingService.removeItemFromIndex({
|
89
|
+
collectionUid: event.model.uid,
|
90
|
+
recordId: updatedItemIds[k]
|
91
|
+
});
|
92
|
+
}
|
93
|
+
}
|
94
|
+
else
|
95
|
+
{
|
96
|
+
for (let k = 0; k< updatedItemIds.length; k++)
|
97
|
+
{
|
98
|
+
await scheduleIndexingService.addItemToIndex({
|
99
|
+
collectionUid: event.model.uid,
|
100
|
+
recordId: updatedItemIds[k]
|
101
|
+
});
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}
|
107
|
+
if (event.action === 'afterDelete') {
|
108
|
+
if (strapi.elasticsearch.collections.includes(event.model.uid))
|
109
|
+
{
|
110
|
+
await scheduleIndexingService.removeItemFromIndex({
|
111
|
+
collectionUid: event.model.uid,
|
112
|
+
recordId: event.result.id
|
113
|
+
});
|
114
|
+
}
|
115
|
+
}
|
116
|
+
if (event.action === 'afterDeleteMany') {
|
117
|
+
if (strapi.elasticsearch.collections.includes(event.model.uid))
|
118
|
+
{
|
119
|
+
if (Object.keys(event.params.where).includes('$and') &&
|
120
|
+
Array.isArray(event.params.where['$and']) &&
|
121
|
+
Object.keys(event.params.where['$and'][0]).includes('id') &&
|
122
|
+
Object.keys(event.params.where['$and'][0]['id']).includes('$in'))
|
123
|
+
{
|
124
|
+
const deletedItemIds = event.params.where['$and'][0]['id']['$in']
|
125
|
+
for (let k = 0; k< deletedItemIds.length; k++)
|
126
|
+
{
|
127
|
+
await scheduleIndexingService.removeItemFromIndex({
|
128
|
+
collectionUid: event.model.uid,
|
129
|
+
recordId: deletedItemIds[k]
|
130
|
+
});
|
131
|
+
}
|
132
|
+
}
|
133
|
+
}
|
134
|
+
}
|
135
|
+
});
|
136
|
+
configureIndexingService.markInitialized();
|
137
|
+
}
|
138
|
+
catch(err) {
|
139
|
+
console.error('An error was encountered while initializing the strapi-plugin-elasticsearch plugin.')
|
140
|
+
console.error(err);
|
141
|
+
}
|
142
|
+
};
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module.exports = {
|
2
|
+
"kind": "collectionType",
|
3
|
+
"collectionName": "indexing-log",
|
4
|
+
"info": {
|
5
|
+
"singularName": "indexing-log",
|
6
|
+
"pluralName": "indexing-logs",
|
7
|
+
"displayName": "Indexing Logs",
|
8
|
+
"description": "Logged runs of the indexing cron job"
|
9
|
+
},
|
10
|
+
"options": {
|
11
|
+
"draftAndPublish": false
|
12
|
+
},
|
13
|
+
"pluginOptions": {
|
14
|
+
'content-manager': {
|
15
|
+
visible: false,
|
16
|
+
},
|
17
|
+
'content-type-builder': {
|
18
|
+
visible: false,
|
19
|
+
}
|
20
|
+
},
|
21
|
+
"attributes": {
|
22
|
+
"status": {
|
23
|
+
"type": "enumeration",
|
24
|
+
"enum": [
|
25
|
+
"pass",
|
26
|
+
"fail"
|
27
|
+
],
|
28
|
+
"required": true
|
29
|
+
},
|
30
|
+
"details": {
|
31
|
+
"type": "text"
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
File without changes
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module.exports = {
|
2
|
+
"kind": "collectionType",
|
3
|
+
"collectionName": "task",
|
4
|
+
"info": {
|
5
|
+
"singularName": "task",
|
6
|
+
"pluralName": "tasks",
|
7
|
+
"displayName": "Task",
|
8
|
+
"description": "Search indexing tasks"
|
9
|
+
},
|
10
|
+
"options": {
|
11
|
+
"draftAndPublish": false
|
12
|
+
},
|
13
|
+
"pluginOptions": {
|
14
|
+
'content-manager': {
|
15
|
+
visible: false,
|
16
|
+
},
|
17
|
+
'content-type-builder': {
|
18
|
+
visible: false,
|
19
|
+
}
|
20
|
+
},
|
21
|
+
"attributes": {
|
22
|
+
"collection_name": {
|
23
|
+
"type": "string",
|
24
|
+
"required": true
|
25
|
+
},
|
26
|
+
"item_id": {
|
27
|
+
"type": "integer"
|
28
|
+
},
|
29
|
+
"indexing_status": {
|
30
|
+
"type": "enumeration",
|
31
|
+
"enum": [
|
32
|
+
"to-be-done",
|
33
|
+
"done"
|
34
|
+
],
|
35
|
+
"required": true,
|
36
|
+
"default": "to-be-done"
|
37
|
+
},
|
38
|
+
"full_site_indexing": {
|
39
|
+
"type": "boolean"
|
40
|
+
},
|
41
|
+
"indexing_type": {
|
42
|
+
"type": "enumeration",
|
43
|
+
"enum": [
|
44
|
+
"add-to-index",
|
45
|
+
"remove-from-index"
|
46
|
+
],
|
47
|
+
"default": "add-to-index",
|
48
|
+
"required": true
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
@@ -0,0 +1,66 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
module.exports = ({ strapi }) => {
|
6
|
+
const configureIndexingService = strapi.plugins['elasticsearch'].services.configureIndexing;
|
7
|
+
|
8
|
+
const getContentConfig = async (ctx) => {
|
9
|
+
return configureIndexingService.getContentConfig();
|
10
|
+
};
|
11
|
+
|
12
|
+
const saveCollectionConfig = async (ctx) => {
|
13
|
+
const { body } = ctx.request;
|
14
|
+
try {
|
15
|
+
const updatedConfig = await configureIndexingService.setContentConfig({collection: ctx.params.collectionname, config : body.data});
|
16
|
+
return updatedConfig;
|
17
|
+
} catch (err) {
|
18
|
+
ctx.throw(500, err);
|
19
|
+
}
|
20
|
+
};
|
21
|
+
|
22
|
+
const importContentConfig = async (ctx) => {
|
23
|
+
const { body } = ctx.request;
|
24
|
+
try {
|
25
|
+
if (body['data'])
|
26
|
+
{
|
27
|
+
const updatedConfig = await configureIndexingService.importContentConfig({config : body['data']});
|
28
|
+
return updatedConfig;
|
29
|
+
}
|
30
|
+
else
|
31
|
+
ctx.throw(400, 'Invalid parameters')
|
32
|
+
} catch (err) {
|
33
|
+
ctx.throw(500, err);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
const exportContentConfig = async (ctx) => {
|
38
|
+
return configureIndexingService.getContentConfig();
|
39
|
+
}
|
40
|
+
|
41
|
+
const setContentConfig = async (ctx) => {
|
42
|
+
const { body } = ctx.request;
|
43
|
+
try {
|
44
|
+
const updatedConfig = await configureIndexingService.setContentConfig({config : body});
|
45
|
+
return updatedConfig;
|
46
|
+
} catch (err) {
|
47
|
+
ctx.throw(500, err);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
const getCollectionConfig = async (ctx) => {
|
52
|
+
if (ctx.params.collectionname)
|
53
|
+
return configureIndexingService.getCollectionConfig({collectionName: ctx.params.collectionname})
|
54
|
+
else
|
55
|
+
return null;
|
56
|
+
}
|
57
|
+
|
58
|
+
return {
|
59
|
+
getContentConfig,
|
60
|
+
setContentConfig,
|
61
|
+
getCollectionConfig,
|
62
|
+
saveCollectionConfig,
|
63
|
+
exportContentConfig,
|
64
|
+
importContentConfig
|
65
|
+
};
|
66
|
+
};
|
@@ -0,0 +1,15 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const configureIndexing = require('./configure-indexing');
|
4
|
+
const performSearch = require('./perform-search');
|
5
|
+
const logIndexing = require('./log-indexing');
|
6
|
+
const setupInfo = require('./setup-info');
|
7
|
+
const performIndexing = require('./perform-indexing');
|
8
|
+
|
9
|
+
module.exports = {
|
10
|
+
configureIndexing,
|
11
|
+
performSearch,
|
12
|
+
logIndexing,
|
13
|
+
setupInfo,
|
14
|
+
performIndexing
|
15
|
+
};
|
@@ -0,0 +1,11 @@
|
|
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
|
+
return {
|
9
|
+
fetchRecentRunsLog
|
10
|
+
};
|
11
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
module.exports = ({ strapi }) => {
|
6
|
+
const indexer = strapi.plugins['elasticsearch'].services.indexer;
|
7
|
+
const scheduleIndexingService = strapi.plugins['elasticsearch'].services.scheduleIndexing;
|
8
|
+
const rebuildIndex = async (ctx) => {
|
9
|
+
return await indexer.rebuildIndex();
|
10
|
+
}
|
11
|
+
|
12
|
+
const indexCollection = async (ctx) => {
|
13
|
+
if (ctx.params.collectionname)
|
14
|
+
return await scheduleIndexingService.addCollectionToIndex({collectionUid: ctx.params.collectionname})
|
15
|
+
else
|
16
|
+
return null;
|
17
|
+
}
|
18
|
+
|
19
|
+
const triggerIndexingTask = async (ctx) => {
|
20
|
+
return await indexer.indexPendingData()
|
21
|
+
}
|
22
|
+
|
23
|
+
return {
|
24
|
+
rebuildIndex,
|
25
|
+
indexCollection,
|
26
|
+
triggerIndexingTask
|
27
|
+
};
|
28
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const qs = require('qs');
|
4
|
+
|
5
|
+
module.exports = {
|
6
|
+
search : async (ctx) => {
|
7
|
+
try {
|
8
|
+
const esInterface = strapi.plugins['elasticsearch'].services.esInterface;
|
9
|
+
if (ctx.query.query)
|
10
|
+
{
|
11
|
+
const query = qs.parse(ctx.query.query);
|
12
|
+
const resp = await esInterface.searchData(query);
|
13
|
+
if (resp?.hits?.hits)
|
14
|
+
{
|
15
|
+
const filteredData = resp.hits.hits.filter(dt => dt._source !== null);
|
16
|
+
const filteredMatches = filteredData.map((dt) => dt['_source']);
|
17
|
+
ctx.body = filteredMatches;
|
18
|
+
}
|
19
|
+
else
|
20
|
+
ctx.body = {}
|
21
|
+
}
|
22
|
+
else
|
23
|
+
ctx.body = {}
|
24
|
+
} catch (err) {
|
25
|
+
ctx.response.status = 500;
|
26
|
+
ctx.body = "An error was encountered while processing the search request."
|
27
|
+
console.log('An error was encountered while processing the search request.')
|
28
|
+
console.log(err);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
module.exports = ({ strapi }) => {
|
6
|
+
const helperService = strapi.plugins['elasticsearch'].services.helper;
|
7
|
+
const getElasticsearchInfo = async (ctx) => {
|
8
|
+
return helperService.getElasticsearchInfo();
|
9
|
+
}
|
10
|
+
|
11
|
+
return {
|
12
|
+
getElasticsearchInfo,
|
13
|
+
};
|
14
|
+
}
|
package/server/index.js
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const register = require('./register');
|
4
|
+
const bootstrap = require('./bootstrap');
|
5
|
+
const destroy = require('./destroy');
|
6
|
+
const config = require('./config');
|
7
|
+
const contentTypes = require('./content-types');
|
8
|
+
const controllers = require('./controllers');
|
9
|
+
const routes = require('./routes');
|
10
|
+
const middlewares = require('./middlewares');
|
11
|
+
const policies = require('./policies');
|
12
|
+
const services = require('./services');
|
13
|
+
|
14
|
+
module.exports = {
|
15
|
+
register,
|
16
|
+
bootstrap,
|
17
|
+
destroy,
|
18
|
+
config,
|
19
|
+
controllers,
|
20
|
+
routes,
|
21
|
+
services,
|
22
|
+
contentTypes,
|
23
|
+
policies,
|
24
|
+
middlewares,
|
25
|
+
};
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module.exports = {
|
2
|
+
// accessible only from admin UI
|
3
|
+
type: 'admin',
|
4
|
+
routes: [
|
5
|
+
{
|
6
|
+
method: 'GET',
|
7
|
+
path: '/content-config',
|
8
|
+
handler: 'configureIndexing.getContentConfig',
|
9
|
+
config: { policies: [] },
|
10
|
+
},
|
11
|
+
{
|
12
|
+
method: 'GET',
|
13
|
+
path: '/collection-config/:collectionname',
|
14
|
+
handler: 'configureIndexing.getCollectionConfig',
|
15
|
+
config: { policies: [] },
|
16
|
+
},
|
17
|
+
{
|
18
|
+
method: 'POST',
|
19
|
+
path: '/collection-config/:collectionname',
|
20
|
+
handler: 'configureIndexing.saveCollectionConfig',
|
21
|
+
config: { policies: [] },
|
22
|
+
},
|
23
|
+
{
|
24
|
+
method: 'POST',
|
25
|
+
path: '/content-config',
|
26
|
+
handler: 'configureIndexing.setContentConfig',
|
27
|
+
config: { policies: [] },
|
28
|
+
},
|
29
|
+
{
|
30
|
+
method: 'GET',
|
31
|
+
path: '/export-content-config',
|
32
|
+
handler: 'configureIndexing.exportContentConfig',
|
33
|
+
config: { policies: [] },
|
34
|
+
},
|
35
|
+
{
|
36
|
+
method: 'POST',
|
37
|
+
path: '/import-content-config',
|
38
|
+
handler: 'configureIndexing.importContentConfig',
|
39
|
+
config: { policies: [] },
|
40
|
+
},
|
41
|
+
],
|
42
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
const configureIndexingRoutes = require('./configure-indexing');
|
2
|
+
const performSearch = require('./perform-search');
|
3
|
+
const runLog = require('./run-log');
|
4
|
+
const setupInfo = require('./setup-info');
|
5
|
+
const performIndexing = require('./perform-indexing');
|
6
|
+
|
7
|
+
module.exports = {
|
8
|
+
config: configureIndexingRoutes,
|
9
|
+
search: performSearch,
|
10
|
+
runLog: runLog,
|
11
|
+
setupInfo: setupInfo,
|
12
|
+
performIndexing: performIndexing
|
13
|
+
};
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module.exports = {
|
2
|
+
// accessible only from admin UI
|
3
|
+
type: 'admin',
|
4
|
+
routes: [
|
5
|
+
{
|
6
|
+
method: 'GET',
|
7
|
+
path: '/reindex',
|
8
|
+
handler: 'performIndexing.rebuildIndex',
|
9
|
+
config: { policies: [] },
|
10
|
+
},
|
11
|
+
{
|
12
|
+
method: 'GET',
|
13
|
+
path: '/collection-reindex/:collectionname',
|
14
|
+
handler: 'performIndexing.indexCollection',
|
15
|
+
config: { policies: [] },
|
16
|
+
},
|
17
|
+
{
|
18
|
+
method: 'GET',
|
19
|
+
path: '/trigger-indexing/',
|
20
|
+
handler: 'performIndexing.triggerIndexingTask',
|
21
|
+
config: { policies: [] },
|
22
|
+
},
|
23
|
+
],
|
24
|
+
};
|