@socialgouv/cdtn-elasticsearch 2.43.0 → 2.44.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/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.0](https://github.com/SocialGouv/cdtn-admin/compare/v2.43.0...v2.44.0) (2024-06-04)
7
+
8
+ ### Features
9
+
10
+ - **elasticsearch:** upgrade to v8 ([#1389](https://github.com/SocialGouv/cdtn-admin/issues/1389)) ([b1f8598](https://github.com/SocialGouv/cdtn-admin/commit/b1f85983fed17123990d9f3c0fc417ea7534c24c))
11
+
6
12
  # [2.43.0](https://github.com/SocialGouv/cdtn-admin/compare/v2.42.8...v2.43.0) (2024-06-04)
7
13
 
8
14
  **Note:** Version bump only for package @socialgouv/cdtn-elasticsearch
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@socialgouv/cdtn-elasticsearch",
3
3
  "description": "SocialGouv - Code du travail numerique - Infrastructure - Elasticsearch",
4
- "version": "2.43.0",
4
+ "version": "2.44.0",
5
5
  "babel": {
6
6
  "plugins": [
7
7
  "@babel/plugin-transform-modules-commonjs"
@@ -13,9 +13,6 @@
13
13
  },
14
14
  "license": "Apache-2.0",
15
15
  "main": "src/index.js",
16
- "peerDependencies": {
17
- "@elastic/elasticsearch": "7.x"
18
- },
19
16
  "publishConfig": {
20
17
  "access": "public"
21
18
  },
@@ -44,5 +41,5 @@
44
41
  },
45
42
  "sideEffects": false,
46
43
  "types": "src/index.d.ts",
47
- "gitHead": "b0fab0cc92887cba5f29fbc2ffb6201ec8558bc7"
44
+ "gitHead": "2b7f9e5974ebc7db3b48b234319b686f4af5c430"
48
45
  }
package/src/analysis.js CHANGED
@@ -66,51 +66,51 @@ const analyzer = {
66
66
  // for all suggestion
67
67
  // see below, ngram from tokens
68
68
  autocomplete: {
69
- filter: ["lowercase", "icu_folding"],
69
+ filter: ["lowercase", "asciifolding"],
70
70
  tokenizer: "autocomplete", //, "french_stop"]
71
71
  },
72
72
 
73
73
  // at search time, we only consider
74
74
  // the entire query (no ngrams)
75
75
  autocomplete_search: {
76
- filter: "icu_folding",
77
76
  tokenizer: "lowercase",
77
+ filter: "asciifolding",
78
78
  },
79
79
 
80
80
  french: {
81
81
  filter: [
82
82
  "french_elision",
83
- "icu_folding",
83
+ "asciifolding",
84
84
  "lowercase",
85
85
  "french_stop",
86
86
  "french_stemmer",
87
87
  ],
88
- tokenizer: "icu_tokenizer",
88
+ tokenizer: "standard",
89
89
  },
90
90
 
91
91
  french_indexing: {
92
92
  char_filter: ["startwith"],
93
93
  filter: [
94
94
  "french_elision",
95
- "icu_folding",
95
+ "asciifolding",
96
96
  "lowercase",
97
97
  "french_stop",
98
98
  "french_stemmer",
99
99
  ],
100
- tokenizer: "icu_tokenizer",
100
+ tokenizer: "standard",
101
101
  },
102
102
 
103
103
  french_with_synonyms: {
104
104
  char_filter: ["html_strip"],
105
105
  filter: [
106
106
  "french_elision",
107
- "icu_folding",
107
+ "asciifolding",
108
108
  "lowercase",
109
109
  "french_synonyms",
110
110
  "french_stop",
111
111
  "french_stemmer",
112
112
  ],
113
- tokenizer: "icu_tokenizer",
113
+ tokenizer: "standard",
114
114
  },
115
115
 
116
116
  idcc_ape: {
@@ -122,8 +122,8 @@ const analyzer = {
122
122
  // (as opposite to match "in the middle")
123
123
  sugg_prefix: {
124
124
  char_filter: ["startwith"],
125
- filter: ["lowercase", "icu_folding"],
126
- tokenizer: "icu_tokenizer",
125
+ filter: ["lowercase", "asciifolding"],
126
+ tokenizer: "standard",
127
127
  },
128
128
  };
129
129
 
@@ -3,7 +3,7 @@ const { logger } = require("@shared/utils");
3
3
  const { analyzer, char_filter, filter, tokenizer } = require("./analysis");
4
4
 
5
5
  async function createIndex({ client, indexName, mappings }) {
6
- const { body } = await client.indices.exists({ index: indexName });
6
+ const body = await client.indices.exists({ index: indexName });
7
7
  if (body) {
8
8
  try {
9
9
  await client.indices.delete({ index: indexName });
@@ -38,7 +38,7 @@ async function createIndex({ client, indexName, mappings }) {
38
38
  }
39
39
 
40
40
  async function version({ client }) {
41
- const { body } = await client.info();
41
+ const body = await client.info();
42
42
  logger.info(body.version.number);
43
43
  }
44
44
 
@@ -63,10 +63,8 @@ async function bulkIndexDocuments({ client, indexName, documents }) {
63
63
  ),
64
64
  index: indexName,
65
65
  });
66
- if (resp.body.errors) {
67
- const errorDocs = resp.body.items.filter(
68
- (item) => item.index.status !== 201
69
- );
66
+ if (resp.errors) {
67
+ const errorDocs = resp.items.filter((item) => item.index.status !== 201);
70
68
  throw new Error(`Error during indexing ${JSON.stringify(errorDocs)}`);
71
69
  }
72
70
  logger.info(`Index ${documents.length} documents.`);
@@ -89,7 +87,7 @@ async function indexDocumentsBatched({
89
87
  }
90
88
 
91
89
  async function deleteOldIndex({ client, patterns, timestamp }) {
92
- const { body: indices } = await client.cat.indices({ format: "json" });
90
+ const indices = await client.cat.indices({ format: "json" });
93
91
 
94
92
  const IndicesToDelete = getIndicesToDelete(patterns, timestamp, indices);
95
93
  const pIndicesToDelete = IndicesToDelete.map(({ index }) =>