@socialgouv/cdtn-elasticsearch 2.44.0 → 2.44.1
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/CHANGELOG.md +6 -0
- package/package.json +2 -3
- package/src/esClientUtils.js +9 -11
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.44.1](https://github.com/SocialGouv/cdtn-admin/compare/v2.44.0...v2.44.1) (2024-06-04)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **cdtn-elasticsearch:** use `console` instead of `logger` ([#1419](https://github.com/SocialGouv/cdtn-admin/issues/1419)) ([f08b17a](https://github.com/SocialGouv/cdtn-admin/commit/f08b17ae7d5c5f607e391b7774cdd272314be1d3))
|
|
11
|
+
|
|
6
12
|
# [2.44.0](https://github.com/SocialGouv/cdtn-admin/compare/v2.43.0...v2.44.0) (2024-06-04)
|
|
7
13
|
|
|
8
14
|
### Features
|
package/package.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socialgouv/cdtn-elasticsearch",
|
|
3
3
|
"description": "SocialGouv - Code du travail numerique - Infrastructure - Elasticsearch",
|
|
4
|
-
"version": "2.44.
|
|
4
|
+
"version": "2.44.1",
|
|
5
5
|
"babel": {
|
|
6
6
|
"plugins": [
|
|
7
7
|
"@babel/plugin-transform-modules-commonjs"
|
|
8
8
|
]
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@shared/utils": "workspace:^",
|
|
12
11
|
"got": "^11.8.2"
|
|
13
12
|
},
|
|
14
13
|
"license": "Apache-2.0",
|
|
@@ -41,5 +40,5 @@
|
|
|
41
40
|
},
|
|
42
41
|
"sideEffects": false,
|
|
43
42
|
"types": "src/index.d.ts",
|
|
44
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "b33ab8fdff778b59508e9988d2998b91edb32058"
|
|
45
44
|
}
|
package/src/esClientUtils.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
const { logger } = require("@shared/utils");
|
|
2
|
-
|
|
3
1
|
const { analyzer, char_filter, filter, tokenizer } = require("./analysis");
|
|
4
2
|
|
|
5
3
|
async function createIndex({ client, indexName, mappings }) {
|
|
@@ -7,9 +5,9 @@ async function createIndex({ client, indexName, mappings }) {
|
|
|
7
5
|
if (body) {
|
|
8
6
|
try {
|
|
9
7
|
await client.indices.delete({ index: indexName });
|
|
10
|
-
|
|
8
|
+
console.info(`Index ${indexName} deleted.`);
|
|
11
9
|
} catch (error) {
|
|
12
|
-
|
|
10
|
+
console.error("index delete", error);
|
|
13
11
|
}
|
|
14
12
|
}
|
|
15
13
|
try {
|
|
@@ -31,15 +29,15 @@ async function createIndex({ client, indexName, mappings }) {
|
|
|
31
29
|
},
|
|
32
30
|
index: indexName,
|
|
33
31
|
});
|
|
34
|
-
|
|
32
|
+
console.info(`Index ${indexName} created.`);
|
|
35
33
|
} catch (error) {
|
|
36
|
-
|
|
34
|
+
console.error("index create", error);
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
async function version({ client }) {
|
|
41
39
|
const body = await client.info();
|
|
42
|
-
|
|
40
|
+
console.info(body.version.number);
|
|
43
41
|
}
|
|
44
42
|
|
|
45
43
|
async function bulkIndexDocuments({ client, indexName, documents }) {
|
|
@@ -67,9 +65,9 @@ async function bulkIndexDocuments({ client, indexName, documents }) {
|
|
|
67
65
|
const errorDocs = resp.items.filter((item) => item.index.status !== 201);
|
|
68
66
|
throw new Error(`Error during indexing ${JSON.stringify(errorDocs)}`);
|
|
69
67
|
}
|
|
70
|
-
|
|
68
|
+
console.info(`Index ${documents.length} documents.`);
|
|
71
69
|
} catch (error) {
|
|
72
|
-
|
|
70
|
+
console.error(`Failed to index documents (${error})`);
|
|
73
71
|
throw error;
|
|
74
72
|
}
|
|
75
73
|
}
|
|
@@ -80,7 +78,7 @@ async function indexDocumentsBatched({
|
|
|
80
78
|
documents,
|
|
81
79
|
size = 500,
|
|
82
80
|
}) {
|
|
83
|
-
|
|
81
|
+
console.info(`Loaded ${documents.length} documents`);
|
|
84
82
|
for (const chunk of chunks(documents, size)) {
|
|
85
83
|
await bulkIndexDocuments({ client, documents: chunk, indexName });
|
|
86
84
|
}
|
|
@@ -95,7 +93,7 @@ async function deleteOldIndex({ client, patterns, timestamp }) {
|
|
|
95
93
|
);
|
|
96
94
|
|
|
97
95
|
return Promise.all(pIndicesToDelete).then(() => {
|
|
98
|
-
|
|
96
|
+
console.info(
|
|
99
97
|
`Remove ${pIndicesToDelete.length} old indices (${JSON.stringify(
|
|
100
98
|
IndicesToDelete
|
|
101
99
|
)})`
|