@terascope/elasticsearch-api 3.6.0 → 3.6.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/index.js +6 -1
- package/package.json +9 -9
- package/test/bulk-send-dlq-spec.js +7 -27
- package/test/bulk-send-limit-spec.js +2 -22
package/index.js
CHANGED
|
@@ -971,6 +971,11 @@ module.exports = function elasticsearchApi(client, logger, _opConfig) {
|
|
|
971
971
|
return distribution === ElasticsearchDistribution.elasticsearch && majorVersion === 8;
|
|
972
972
|
}
|
|
973
973
|
|
|
974
|
+
function isOpensearch2() {
|
|
975
|
+
const { distribution, majorVersion } = getClientMetadata();
|
|
976
|
+
return distribution === ElasticsearchDistribution.opensearch && majorVersion === 2;
|
|
977
|
+
}
|
|
978
|
+
|
|
974
979
|
function _fixMappingRequest(_params, isTemplate) {
|
|
975
980
|
if (!_params || !_params.body) {
|
|
976
981
|
throw new Error('Invalid mapping request');
|
|
@@ -1000,7 +1005,7 @@ module.exports = function elasticsearchApi(client, logger, _opConfig) {
|
|
|
1000
1005
|
}
|
|
1001
1006
|
}
|
|
1002
1007
|
|
|
1003
|
-
if (isElasticsearch8(client)) {
|
|
1008
|
+
if (isElasticsearch8(client) || isOpensearch2(client)) {
|
|
1004
1009
|
delete defaultParams.includeTypeName;
|
|
1005
1010
|
}
|
|
1006
1011
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terascope/elasticsearch-api",
|
|
3
3
|
"displayName": "Elasticsearch API",
|
|
4
|
-
"version": "3.6.
|
|
4
|
+
"version": "3.6.2",
|
|
5
5
|
"description": "Elasticsearch client api used across multiple services, handles retries and exponential backoff",
|
|
6
6
|
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/elasticsearch-api#readme",
|
|
7
7
|
"bugs": {
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"main": "index.js",
|
|
14
14
|
"typings": "types/index.d.ts",
|
|
15
15
|
"scripts": {
|
|
16
|
-
"test": "ts-scripts test . --",
|
|
17
|
-
"test:7": "ELASTICSEARCH_VERSION='7.9.3'
|
|
18
|
-
"test:8": "ELASTICSEARCH_VERSION='8.1.2'
|
|
19
|
-
"test:debug": "ts-scripts test --debug . --",
|
|
20
|
-
"test:legacy": "LEGACY_CLIENT=true
|
|
21
|
-
"test:opensearch": "
|
|
22
|
-
"test:watch": "ts-scripts test --watch . --"
|
|
16
|
+
"test": "TEST_RESTRAINED_ELASTICSEARCH='true' ts-scripts test . --",
|
|
17
|
+
"test:7": "TEST_RESTRAINED_ELASTICSEARCH='true' ELASTICSEARCH_VERSION='7.9.3' ts-scripts test . --",
|
|
18
|
+
"test:8": "TEST_RESTRAINED_ELASTICSEARCH='true' ELASTICSEARCH_VERSION='8.1.2' ts-scripts test . --",
|
|
19
|
+
"test:debug": "TEST_RESTRAINED_ELASTICSEARCH='true' ts-scripts test --debug . --",
|
|
20
|
+
"test:legacy": "TEST_RESTRAINED_ELASTICSEARCH='true' LEGACY_CLIENT=true ts-scripts test . --",
|
|
21
|
+
"test:opensearch": "TEST_RESTRAINED_OPENSEARCH='true' ts-scripts test --debug . --",
|
|
22
|
+
"test:watch": "TEST_RESTRAINED_ELASTICSEARCH='true' ts-scripts test --watch . --"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@terascope/types": "^0.11.2",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@opensearch-project/opensearch": "^1.2.0",
|
|
32
32
|
"@types/elasticsearch": "^5.0.40",
|
|
33
33
|
"elasticsearch": "^15.4.1",
|
|
34
|
-
"elasticsearch-store": "^0.67.
|
|
34
|
+
"elasticsearch-store": "^0.67.3",
|
|
35
35
|
"elasticsearch6": "npm:@elastic/elasticsearch@^6.7.0",
|
|
36
36
|
"elasticsearch7": "npm:@elastic/elasticsearch@^7.0.0",
|
|
37
37
|
"elasticsearch8": "npm:@elastic/elasticsearch@^8.0.0"
|
|
@@ -9,37 +9,18 @@ const { ElasticsearchTestHelpers } = require('elasticsearch-store');
|
|
|
9
9
|
const elasticsearchAPI = require('../index');
|
|
10
10
|
|
|
11
11
|
const {
|
|
12
|
-
makeClient, cleanupIndex,
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
makeClient, cleanupIndex, EvenDateData,
|
|
13
|
+
TEST_INDEX_PREFIX, createMappingFromDatatype,
|
|
14
|
+
formatUploadData
|
|
15
15
|
} = ElasticsearchTestHelpers;
|
|
16
16
|
|
|
17
17
|
const THREE_MINUTES = 3 * 60 * 1000;
|
|
18
18
|
|
|
19
19
|
jest.setTimeout(THREE_MINUTES + 60000);
|
|
20
20
|
|
|
21
|
-
function formatUploadData(
|
|
22
|
-
index, data, isES8ClientTest = false
|
|
23
|
-
) {
|
|
24
|
-
const results = [];
|
|
25
|
-
|
|
26
|
-
data.forEach((record, i) => {
|
|
27
|
-
const meta = { _index: index, _id: i + 1 };
|
|
28
|
-
|
|
29
|
-
if (!isES8ClientTest) {
|
|
30
|
-
meta._type = '_doc';
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
results.push({ action: { index: meta }, data: record });
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
return results;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
21
|
describe('bulkSend', () => {
|
|
40
22
|
let client;
|
|
41
23
|
let api;
|
|
42
|
-
let isElasticsearch8 = false;
|
|
43
24
|
|
|
44
25
|
beforeAll(async () => {
|
|
45
26
|
client = await makeClient();
|
|
@@ -52,7 +33,6 @@ describe('bulkSend', () => {
|
|
|
52
33
|
beforeAll(async () => {
|
|
53
34
|
await cleanupIndex(client, index);
|
|
54
35
|
api = elasticsearchAPI(client, logger, { _dead_letter_action: 'kafka_dead_letter' });
|
|
55
|
-
isElasticsearch8 = api.isElasticsearch8();
|
|
56
36
|
|
|
57
37
|
const overrides = {
|
|
58
38
|
settings: {
|
|
@@ -79,7 +59,7 @@ describe('bulkSend', () => {
|
|
|
79
59
|
|
|
80
60
|
const docs = cloneDeep(EvenDateData.data.slice(0, 2));
|
|
81
61
|
|
|
82
|
-
const result = await diffApi.bulkSend(formatUploadData(index, docs,
|
|
62
|
+
const result = await diffApi.bulkSend(formatUploadData(index, docs, true));
|
|
83
63
|
|
|
84
64
|
expect(result).toBe(2);
|
|
85
65
|
});
|
|
@@ -91,7 +71,7 @@ describe('bulkSend', () => {
|
|
|
91
71
|
|
|
92
72
|
docs[0].bytes = 'this is a bad value';
|
|
93
73
|
|
|
94
|
-
await expect(diffApi.bulkSend(formatUploadData(index, docs,
|
|
74
|
+
await expect(diffApi.bulkSend(formatUploadData(index, docs, true)))
|
|
95
75
|
.rejects.toThrow();
|
|
96
76
|
});
|
|
97
77
|
|
|
@@ -101,7 +81,7 @@ describe('bulkSend', () => {
|
|
|
101
81
|
|
|
102
82
|
docs[0].bytes = 'this is a bad value';
|
|
103
83
|
|
|
104
|
-
const result = await api.bulkSend(formatUploadData(index, docs,
|
|
84
|
+
const result = await api.bulkSend(formatUploadData(index, docs, true));
|
|
105
85
|
|
|
106
86
|
// 1 good doc - so only 1 row affected
|
|
107
87
|
expect(result).toBe(1);
|
|
@@ -113,7 +93,7 @@ describe('bulkSend', () => {
|
|
|
113
93
|
it('should return a count if not un-retryable records if dlq is set', async () => {
|
|
114
94
|
const docs = cloneDeep(EvenDateData.data.slice(0, 2));
|
|
115
95
|
|
|
116
|
-
const result = await api.bulkSend(formatUploadData(index, docs,
|
|
96
|
+
const result = await api.bulkSend(formatUploadData(index, docs, true));
|
|
117
97
|
|
|
118
98
|
expect(result).toBe(2);
|
|
119
99
|
});
|
|
@@ -10,35 +10,16 @@ const elasticsearchAPI = require('../index');
|
|
|
10
10
|
|
|
11
11
|
const {
|
|
12
12
|
makeClient, cleanupIndex, waitForData,
|
|
13
|
-
EvenDateData, TEST_INDEX_PREFIX
|
|
13
|
+
EvenDateData, TEST_INDEX_PREFIX, formatUploadData
|
|
14
14
|
} = ElasticsearchTestHelpers;
|
|
15
15
|
|
|
16
16
|
const THREE_MINUTES = 3 * 60 * 1000;
|
|
17
17
|
|
|
18
18
|
jest.setTimeout(THREE_MINUTES + 60000);
|
|
19
19
|
|
|
20
|
-
function formatUploadData(
|
|
21
|
-
index, data, isES8ClientTest = false
|
|
22
|
-
) {
|
|
23
|
-
const results = [];
|
|
24
|
-
|
|
25
|
-
data.forEach((record) => {
|
|
26
|
-
const meta = { _index: index };
|
|
27
|
-
|
|
28
|
-
if (!isES8ClientTest) {
|
|
29
|
-
meta._type = '_doc';
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
results.push({ action: { index: meta }, data: record });
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
return results;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
20
|
describe('bulkSend', () => {
|
|
39
21
|
let client;
|
|
40
22
|
let api;
|
|
41
|
-
let isElasticsearch8 = false;
|
|
42
23
|
|
|
43
24
|
beforeAll(async () => {
|
|
44
25
|
client = await makeClient();
|
|
@@ -51,7 +32,6 @@ describe('bulkSend', () => {
|
|
|
51
32
|
beforeAll(async () => {
|
|
52
33
|
await cleanupIndex(client, index);
|
|
53
34
|
api = elasticsearchAPI(client, logger);
|
|
54
|
-
isElasticsearch8 = api.isElasticsearch8();
|
|
55
35
|
});
|
|
56
36
|
|
|
57
37
|
afterAll(async () => {
|
|
@@ -62,7 +42,7 @@ describe('bulkSend', () => {
|
|
|
62
42
|
const chunkedData = chunk(EvenDateData.data, 50);
|
|
63
43
|
|
|
64
44
|
await pMap(chunkedData, async (cData) => {
|
|
65
|
-
const formattedData = formatUploadData(index, cData,
|
|
45
|
+
const formattedData = formatUploadData(index, cData, true);
|
|
66
46
|
return api.bulkSend(formattedData);
|
|
67
47
|
}, { concurrency: 9 });
|
|
68
48
|
|