@terascope/elasticsearch-api 4.1.0 → 4.2.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/index.js +16 -13
- package/package.json +3 -3
- package/test/api-spec.js +12 -12
- package/test/bulk-send-limit-spec.js +3 -1
package/index.js
CHANGED
|
@@ -67,13 +67,13 @@ export default function elasticsearchApi(client, logger, _opConfig) {
|
|
|
67
67
|
|
|
68
68
|
function search(query) {
|
|
69
69
|
const {
|
|
70
|
-
_sourceInclude, _source_includes,
|
|
71
|
-
_sourceExclude, _source_excludes,
|
|
70
|
+
_sourceInclude, _source_includes: oldSourIncludes,
|
|
71
|
+
_sourceExclude, _source_excludes: oldSourExcludes,
|
|
72
72
|
...safeQuery
|
|
73
73
|
} = query;
|
|
74
74
|
|
|
75
|
-
const sourceIncludes = _sourceInclude ||
|
|
76
|
-
const sourceExcludes = _sourceExclude ||
|
|
75
|
+
const sourceIncludes = _sourceInclude || oldSourIncludes;
|
|
76
|
+
const sourceExcludes = _sourceExclude || oldSourExcludes;
|
|
77
77
|
|
|
78
78
|
if (sourceIncludes) {
|
|
79
79
|
safeQuery._source_includes = sourceIncludes;
|
|
@@ -352,13 +352,16 @@ export default function elasticsearchApi(client, logger, _opConfig) {
|
|
|
352
352
|
const actionKey = getFirstKey(record.action);
|
|
353
353
|
const { _type, ...withoutTypeAction } = record.action[actionKey];
|
|
354
354
|
// if data is specified return both
|
|
355
|
-
return record.data
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
355
|
+
return record.data
|
|
356
|
+
? [{
|
|
357
|
+
...record.action,
|
|
358
|
+
[actionKey]: withoutTypeAction
|
|
359
|
+
},
|
|
360
|
+
record.data]
|
|
361
|
+
: [{
|
|
362
|
+
...record.action,
|
|
363
|
+
[actionKey]: withoutTypeAction
|
|
364
|
+
}];
|
|
362
365
|
}
|
|
363
366
|
|
|
364
367
|
// if data is specified return both
|
|
@@ -1098,7 +1101,8 @@ export default function elasticsearchApi(client, logger, _opConfig) {
|
|
|
1098
1101
|
});
|
|
1099
1102
|
return Promise.reject(error);
|
|
1100
1103
|
});
|
|
1101
|
-
})
|
|
1104
|
+
})
|
|
1105
|
+
.catch((err) => Promise.reject(err));
|
|
1102
1106
|
}
|
|
1103
1107
|
|
|
1104
1108
|
function _verifyMapping(query, configMapping, recordType) {
|
|
@@ -1175,7 +1179,6 @@ export default function elasticsearchApi(client, logger, _opConfig) {
|
|
|
1175
1179
|
clientName,
|
|
1176
1180
|
_time
|
|
1177
1181
|
) {
|
|
1178
|
-
|
|
1179
1182
|
const giveupAfter = Date.now() + (_time || 10000);
|
|
1180
1183
|
return new Promise((resolve, reject) => {
|
|
1181
1184
|
const attemptToCreateIndex = () => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terascope/elasticsearch-api",
|
|
3
3
|
"displayName": "Elasticsearch API",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.2.0",
|
|
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": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@terascope/types": "^1.1.0",
|
|
28
|
-
"@terascope/utils": "^1.
|
|
28
|
+
"@terascope/utils": "^1.2.0",
|
|
29
29
|
"bluebird": "^3.7.2",
|
|
30
30
|
"setimmediate": "^1.0.5"
|
|
31
31
|
},
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@opensearch-project/opensearch": "^1.2.0",
|
|
34
34
|
"@types/elasticsearch": "^5.0.43",
|
|
35
35
|
"elasticsearch": "^15.4.1",
|
|
36
|
-
"elasticsearch-store": "^1.
|
|
36
|
+
"elasticsearch-store": "^1.2.0",
|
|
37
37
|
"elasticsearch6": "npm:@elastic/elasticsearch@^6.7.0",
|
|
38
38
|
"elasticsearch7": "npm:@elastic/elasticsearch@^7.0.0",
|
|
39
39
|
"elasticsearch8": "npm:@elastic/elasticsearch@^8.0.0"
|
package/test/api-spec.js
CHANGED
|
@@ -731,10 +731,10 @@ describe('elasticsearch-api', () => {
|
|
|
731
731
|
return expect(results).toBeTruthy();
|
|
732
732
|
});
|
|
733
733
|
|
|
734
|
-
it('can warn window size with version', () => {
|
|
734
|
+
it('can warn window size with version', async () => {
|
|
735
735
|
const api = esApi(client, logger, { index: 'some_index' });
|
|
736
|
-
|
|
737
|
-
|
|
736
|
+
// FIXME: this test is only really testing a side effect, need a better test
|
|
737
|
+
expect(api.version).toBeFunction();
|
|
738
738
|
});
|
|
739
739
|
|
|
740
740
|
it('can call putTemplate', async () => {
|
|
@@ -1157,7 +1157,7 @@ describe('elasticsearch-api', () => {
|
|
|
1157
1157
|
expect(api.buildQuery(opConfig3, msg4)).toEqual(makeResponse(opConfig3, msg1, response5));
|
|
1158
1158
|
});
|
|
1159
1159
|
|
|
1160
|
-
it('can set up an index', () => {
|
|
1160
|
+
it('can set up an index', async () => {
|
|
1161
1161
|
const api = esApi(client, logger);
|
|
1162
1162
|
const clusterName = 'teracluster';
|
|
1163
1163
|
const newIndex = 'teracluster__state';
|
|
@@ -1165,17 +1165,17 @@ describe('elasticsearch-api', () => {
|
|
|
1165
1165
|
const recordType = 'state';
|
|
1166
1166
|
const clientName = 'default';
|
|
1167
1167
|
|
|
1168
|
-
|
|
1168
|
+
await expect(api.indexSetup(
|
|
1169
1169
|
clusterName,
|
|
1170
1170
|
newIndex,
|
|
1171
1171
|
migrantIndexName,
|
|
1172
1172
|
template,
|
|
1173
1173
|
recordType,
|
|
1174
1174
|
clientName
|
|
1175
|
-
);
|
|
1175
|
+
)).resolves.not.toThrow();
|
|
1176
1176
|
});
|
|
1177
1177
|
|
|
1178
|
-
it('can set up an index and wait for availability', () => {
|
|
1178
|
+
it('can set up an index and wait for availability', async () => {
|
|
1179
1179
|
const api = esApi(client, logger);
|
|
1180
1180
|
const clusterName = 'teracluster';
|
|
1181
1181
|
const newIndex = 'teracluster__state';
|
|
@@ -1185,7 +1185,7 @@ describe('elasticsearch-api', () => {
|
|
|
1185
1185
|
|
|
1186
1186
|
searchError = true;
|
|
1187
1187
|
|
|
1188
|
-
|
|
1188
|
+
await expect(Promise.all([
|
|
1189
1189
|
waitFor(300, () => {
|
|
1190
1190
|
searchError = false;
|
|
1191
1191
|
}),
|
|
@@ -1197,10 +1197,10 @@ describe('elasticsearch-api', () => {
|
|
|
1197
1197
|
recordType,
|
|
1198
1198
|
clientName
|
|
1199
1199
|
)
|
|
1200
|
-
]);
|
|
1200
|
+
])).resolves.not.toThrow();
|
|
1201
1201
|
});
|
|
1202
1202
|
|
|
1203
|
-
it('can wait for elasticsearch availability', () => {
|
|
1203
|
+
it('can wait for elasticsearch availability', async () => {
|
|
1204
1204
|
const api = esApi(client, logger);
|
|
1205
1205
|
const clusterName = 'teracluster';
|
|
1206
1206
|
const newIndex = 'teracluster__state';
|
|
@@ -1211,7 +1211,7 @@ describe('elasticsearch-api', () => {
|
|
|
1211
1211
|
elasticDown = true;
|
|
1212
1212
|
recoverError = true;
|
|
1213
1213
|
|
|
1214
|
-
|
|
1214
|
+
await expect(Promise.all([
|
|
1215
1215
|
api.indexSetup(
|
|
1216
1216
|
clusterName,
|
|
1217
1217
|
newIndex,
|
|
@@ -1227,7 +1227,7 @@ describe('elasticsearch-api', () => {
|
|
|
1227
1227
|
waitFor(1200, () => {
|
|
1228
1228
|
recoverError = false;
|
|
1229
1229
|
})
|
|
1230
|
-
]);
|
|
1230
|
+
])).resolves.not.toThrow();
|
|
1231
1231
|
});
|
|
1232
1232
|
|
|
1233
1233
|
it('can send template on state mapping changes, does not migrate', async () => {
|
|
@@ -41,7 +41,9 @@ describe('bulkSend', () => {
|
|
|
41
41
|
return api.bulkSend(formattedData);
|
|
42
42
|
}, { concurrency: 9 });
|
|
43
43
|
|
|
44
|
-
await
|
|
44
|
+
await expect(
|
|
45
|
+
waitForData(client, index, EvenDateData.data.length, logger, THREE_MINUTES)
|
|
46
|
+
).resolves.not.toThrow();
|
|
45
47
|
});
|
|
46
48
|
});
|
|
47
49
|
});
|