@opensearch-project/opensearch 2.9.0 → 2.11.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 +36 -1
- package/api/api/rollups.js +249 -0
- package/api/api/transforms.js +304 -0
- package/api/index.js +22 -0
- package/index.d.ts +228 -0
- package/lib/aws/shared.js +74 -28
- package/package.json +7 -3
- package/samples/rollups.js +139 -0
- package/samples/transforms.ts +146 -0
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,41 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
|
11
11
|
### Fixed
|
|
12
12
|
### Security
|
|
13
13
|
|
|
14
|
+
## [2.11.0]
|
|
15
|
+
### Changed
|
|
16
|
+
- Return a transport object from `AwsSigv4SignerTransport.request` that has an `.abort()` method that allows in-flight requests to be canceled
|
|
17
|
+
### Dependencies
|
|
18
|
+
- Bumps `@aws-sdk/types` from 3.577.0 to 3.609.0
|
|
19
|
+
- Bumps `@babel/eslint-parser` from 7.24.7 to 7.24.8
|
|
20
|
+
- Bumps `@types/node` from20.14.2 to 20.14.11
|
|
21
|
+
- Bumps `eslint-plugin-prettier` from 5.1.3 to 5.2.1
|
|
22
|
+
- Bumps `faker` from 5.5.3 to 6.6.6
|
|
23
|
+
- Bumps `prettier` from 3.3.1 to 3.3.3
|
|
24
|
+
- Bumps `rimraf` from 5.0.7 to 6.0.1
|
|
25
|
+
- Bumps `semver` from 7.6.2 to 7.6.3
|
|
26
|
+
- Bumps `simple-git` from 3.24.0 to 3.25.0
|
|
27
|
+
- Bumps `ws` from 7.5.9 to 7.5.10
|
|
28
|
+
### Fixed
|
|
29
|
+
- Add missing types in `package.json` for `aws-v3` ([810](https://github.com/opensearch-project/opensearch-js/pull/810))
|
|
30
|
+
|
|
31
|
+
## [2.10.0]
|
|
32
|
+
### Added
|
|
33
|
+
- Added Rollups API ([744](https://github.com/opensearch-project/opensearch-js/issues/744))
|
|
34
|
+
- Added Transforms API ([744](https://github.com/opensearch-project/opensearch-js/issues/744))
|
|
35
|
+
### Dependencies
|
|
36
|
+
- Bumps `@types/node` from 20.14.0 to 20.14.2
|
|
37
|
+
- Bumps `@babel/eslint-parser` from 7.24.6 to 7.24.7
|
|
38
|
+
- Bumps `prettier` from 3.3.0 to 3.3.1
|
|
39
|
+
|
|
40
|
+
## [2.9.1]
|
|
41
|
+
### Dependencies
|
|
42
|
+
- Bumps `json11` from 1.0.4 to 1.1.2
|
|
43
|
+
- Bumps `graceful-fs` from 4.2.8 to 4.2.10
|
|
44
|
+
- Bumps `picomatch` from 2.3.0 to 2.3.1
|
|
45
|
+
### Security
|
|
46
|
+
- [CVE-2024-4068] Bumps `braces` from 3.0.2 to 3.0.3
|
|
47
|
+
- [CVE-2024-4067] Bumps `micromatch` from 4.0.4 to 4.0.7
|
|
48
|
+
|
|
14
49
|
## [2.9.0]
|
|
15
50
|
### Dependencies
|
|
16
51
|
- Bumps `@aws-sdk/types` from 3.535.0 to 3.577.0
|
|
@@ -235,4 +270,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
|
235
270
|
- Bumps `tsd` from 0.22.0 to 0.24.1
|
|
236
271
|
- Bumps `semver` from 7.3.7 to 7.3.8
|
|
237
272
|
### Fixed
|
|
238
|
-
- Fix mutability of connection headers ([#291](https://github.com/opensearch-project/opensearch-js/issues/291))
|
|
273
|
+
- Fix mutability of connection headers ([#291](https://github.com/opensearch-project/opensearch-js/issues/291))
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*
|
|
5
|
+
* The OpenSearch Contributors require contributions made to
|
|
6
|
+
* this file be licensed under the Apache-2.0 license or a
|
|
7
|
+
* compatible open source license.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
13
|
+
* license agreements. See the NOTICE file distributed with
|
|
14
|
+
* this work for additional information regarding copyright
|
|
15
|
+
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
16
|
+
* the Apache License, Version 2.0 (the "License"); you may
|
|
17
|
+
* not use this file except in compliance with the License.
|
|
18
|
+
* You may obtain a copy of the License at
|
|
19
|
+
*
|
|
20
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
21
|
+
*
|
|
22
|
+
* Unless required by applicable law or agreed to in writing,
|
|
23
|
+
* software distributed under the License is distributed on an
|
|
24
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
25
|
+
* KIND, either express or implied. See the License for the
|
|
26
|
+
* specific language governing permissions and limitations
|
|
27
|
+
* under the License.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
* This file was generated from OpenSearch API Spec. Do not edit it
|
|
32
|
+
* manually. If you want to make changes, either update the spec or
|
|
33
|
+
* the API generator.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
'use strict';
|
|
37
|
+
|
|
38
|
+
/* eslint camelcase: 0 */
|
|
39
|
+
/* eslint no-unused-vars: 0 */
|
|
40
|
+
|
|
41
|
+
const {
|
|
42
|
+
handleError,
|
|
43
|
+
encodePathParam,
|
|
44
|
+
normalizeArguments,
|
|
45
|
+
kConfigurationError,
|
|
46
|
+
} = require('../utils');
|
|
47
|
+
|
|
48
|
+
/** @namespace API-Rollups */
|
|
49
|
+
|
|
50
|
+
function RollupsApi(transport, ConfigurationError) {
|
|
51
|
+
this.transport = transport;
|
|
52
|
+
this[kConfigurationError] = ConfigurationError;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Delete index rollup.
|
|
56
|
+
* <br/> See Also: {@link https://opensearch.org/docs/latest/im-plugin/index-rollups/rollup-api/#delete-an-index-rollup-job - rollups.delete}
|
|
57
|
+
*
|
|
58
|
+
* @memberOf API-Rollups
|
|
59
|
+
*
|
|
60
|
+
* @param {object} params
|
|
61
|
+
* @param {string} params.id - Rollup to access
|
|
62
|
+
*
|
|
63
|
+
* @param {TransportRequestOptions} [options] - Options for {@link Transport#request}
|
|
64
|
+
* @param {function} [callback] - Callback that handles errors and response
|
|
65
|
+
*
|
|
66
|
+
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
|
|
67
|
+
*/
|
|
68
|
+
RollupsApi.prototype.delete = function (params, options, callback) {
|
|
69
|
+
[params, options, callback] = normalizeArguments(params, options, callback);
|
|
70
|
+
|
|
71
|
+
if (params.id == null) {
|
|
72
|
+
const err = new this[kConfigurationError]('Missing required parameter: id');
|
|
73
|
+
return handleError(err, callback);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let { method, body, id, ...querystring } = params;
|
|
77
|
+
id = encodePathParam(id);
|
|
78
|
+
|
|
79
|
+
let path = ['_plugins', '_rollup', 'jobs', id].filter((c) => c != null).join('/');
|
|
80
|
+
method = 'DELETE';
|
|
81
|
+
body = body || '';
|
|
82
|
+
|
|
83
|
+
return this.transport.request({ method, path, querystring, body }, options, callback);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Get an index rollup.
|
|
88
|
+
* <br/> See Also: {@link https://opensearch.org/docs/latest/im-plugin/index-rollups/rollup-api/#get-an-index-rollup-job - rollups.get}
|
|
89
|
+
*
|
|
90
|
+
* @memberOf API-Rollups
|
|
91
|
+
*
|
|
92
|
+
* @param {object} params
|
|
93
|
+
* @param {string} params.id - Rollup to access
|
|
94
|
+
*
|
|
95
|
+
* @param {TransportRequestOptions} [options] - Options for {@link Transport#request}
|
|
96
|
+
* @param {function} [callback] - Callback that handles errors and response
|
|
97
|
+
*
|
|
98
|
+
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
|
|
99
|
+
*/
|
|
100
|
+
RollupsApi.prototype.get = function (params, options, callback) {
|
|
101
|
+
[params, options, callback] = normalizeArguments(params, options, callback);
|
|
102
|
+
|
|
103
|
+
if (params.id == null) {
|
|
104
|
+
const err = new this[kConfigurationError]('Missing required parameter: id');
|
|
105
|
+
return handleError(err, callback);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let { method, body, id, ...querystring } = params;
|
|
109
|
+
id = encodePathParam(id);
|
|
110
|
+
|
|
111
|
+
let path = ['_plugins', '_rollup', 'jobs', id].filter((c) => c != null).join('/');
|
|
112
|
+
method = 'GET';
|
|
113
|
+
body = body || '';
|
|
114
|
+
|
|
115
|
+
return this.transport.request({ method, path, querystring, body }, options, callback);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Create or update index rollup.
|
|
120
|
+
* <br/> See Also: {@link https://opensearch.org/docs/latest/im-plugin/index-rollups/rollup-api/#create-or-update-an-index-rollup-job - rollups.put}
|
|
121
|
+
*
|
|
122
|
+
* @memberOf API-Rollups
|
|
123
|
+
*
|
|
124
|
+
* @param {object} params
|
|
125
|
+
* @param {number} [params.if_seq_no] - Only perform the operation if the document has this sequence number.
|
|
126
|
+
* @param {number} [params.if_primary_term] - Only perform the operation if the document has this primary term.
|
|
127
|
+
* @param {string} params.id - Rollup to access
|
|
128
|
+
* @param {object} [params.body]
|
|
129
|
+
*
|
|
130
|
+
* @param {TransportRequestOptions} [options] - Options for {@link Transport#request}
|
|
131
|
+
* @param {function} [callback] - Callback that handles errors and response
|
|
132
|
+
*
|
|
133
|
+
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
|
|
134
|
+
*/
|
|
135
|
+
RollupsApi.prototype.put = function (params, options, callback) {
|
|
136
|
+
[params, options, callback] = normalizeArguments(params, options, callback);
|
|
137
|
+
|
|
138
|
+
if (params.id == null) {
|
|
139
|
+
const err = new this[kConfigurationError]('Missing required parameter: id');
|
|
140
|
+
return handleError(err, callback);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
let { method, body, id, ...querystring } = params;
|
|
144
|
+
id = encodePathParam(id);
|
|
145
|
+
|
|
146
|
+
let path = ['_plugins', '_rollup', 'jobs', id].filter((c) => c != null).join('/');
|
|
147
|
+
method = 'PUT';
|
|
148
|
+
body = body || '';
|
|
149
|
+
|
|
150
|
+
return this.transport.request({ method, path, querystring, body }, options, callback);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Get a rollup's current status.
|
|
155
|
+
* <br/> See Also: {@link https://opensearch.org/docs/latest/im-plugin/index-rollups/rollup-api/#explain-an-index-rollup-job - rollups.explain}
|
|
156
|
+
*
|
|
157
|
+
* @memberOf API-Rollups
|
|
158
|
+
*
|
|
159
|
+
* @param {object} params
|
|
160
|
+
* @param {string} params.id - Rollup to access
|
|
161
|
+
*
|
|
162
|
+
* @param {TransportRequestOptions} [options] - Options for {@link Transport#request}
|
|
163
|
+
* @param {function} [callback] - Callback that handles errors and response
|
|
164
|
+
*
|
|
165
|
+
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
|
|
166
|
+
*/
|
|
167
|
+
RollupsApi.prototype.explain = function (params, options, callback) {
|
|
168
|
+
[params, options, callback] = normalizeArguments(params, options, callback);
|
|
169
|
+
|
|
170
|
+
if (params.id == null) {
|
|
171
|
+
const err = new this[kConfigurationError]('Missing required parameter: id');
|
|
172
|
+
return handleError(err, callback);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
let { method, body, id, ...querystring } = params;
|
|
176
|
+
id = encodePathParam(id);
|
|
177
|
+
|
|
178
|
+
let path = ['_plugins', '_rollup', 'jobs', id, '_explain'].filter((c) => c != null).join('/');
|
|
179
|
+
method = 'GET';
|
|
180
|
+
body = body || '';
|
|
181
|
+
|
|
182
|
+
return this.transport.request({ method, path, querystring, body }, options, callback);
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Start rollup.
|
|
187
|
+
* <br/> See Also: {@link https://opensearch.org/docs/latest/im-plugin/index-rollups/rollup-api/#start-or-stop-an-index-rollup-job - rollups.start}
|
|
188
|
+
*
|
|
189
|
+
* @memberOf API-Rollups
|
|
190
|
+
*
|
|
191
|
+
* @param {object} params
|
|
192
|
+
* @param {string} params.id - Rollup to access
|
|
193
|
+
*
|
|
194
|
+
* @param {TransportRequestOptions} [options] - Options for {@link Transport#request}
|
|
195
|
+
* @param {function} [callback] - Callback that handles errors and response
|
|
196
|
+
*
|
|
197
|
+
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
|
|
198
|
+
*/
|
|
199
|
+
RollupsApi.prototype.start = function (params, options, callback) {
|
|
200
|
+
[params, options, callback] = normalizeArguments(params, options, callback);
|
|
201
|
+
|
|
202
|
+
if (params.id == null) {
|
|
203
|
+
const err = new this[kConfigurationError]('Missing required parameter: id');
|
|
204
|
+
return handleError(err, callback);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
let { method, body, id, ...querystring } = params;
|
|
208
|
+
id = encodePathParam(id);
|
|
209
|
+
|
|
210
|
+
let path = ['_plugins', '_rollup', 'jobs', id, '_start'].filter((c) => c != null).join('/');
|
|
211
|
+
method = 'POST';
|
|
212
|
+
body = body || '';
|
|
213
|
+
|
|
214
|
+
return this.transport.request({ method, path, querystring, body }, options, callback);
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Stop rollup.
|
|
219
|
+
* <br/> See Also: {@link https://opensearch.org/docs/latest/im-plugin/index-rollups/rollup-api/#start-or-stop-an-index-rollup-job - rollups.stop}
|
|
220
|
+
*
|
|
221
|
+
* @memberOf API-Rollups
|
|
222
|
+
*
|
|
223
|
+
* @param {object} params
|
|
224
|
+
* @param {string} params.id - Rollup to access
|
|
225
|
+
*
|
|
226
|
+
* @param {TransportRequestOptions} [options] - Options for {@link Transport#request}
|
|
227
|
+
* @param {function} [callback] - Callback that handles errors and response
|
|
228
|
+
*
|
|
229
|
+
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
|
|
230
|
+
*/
|
|
231
|
+
RollupsApi.prototype.stop = function (params, options, callback) {
|
|
232
|
+
[params, options, callback] = normalizeArguments(params, options, callback);
|
|
233
|
+
|
|
234
|
+
if (params.id == null) {
|
|
235
|
+
const err = new this[kConfigurationError]('Missing required parameter: id');
|
|
236
|
+
return handleError(err, callback);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
let { method, body, id, ...querystring } = params;
|
|
240
|
+
id = encodePathParam(id);
|
|
241
|
+
|
|
242
|
+
let path = ['_plugins', '_rollup', 'jobs', id, '_stop'].filter((c) => c != null).join('/');
|
|
243
|
+
method = 'POST';
|
|
244
|
+
body = body || '';
|
|
245
|
+
|
|
246
|
+
return this.transport.request({ method, path, querystring, body }, options, callback);
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
module.exports = RollupsApi;
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*
|
|
5
|
+
* The OpenSearch Contributors require contributions made to
|
|
6
|
+
* this file be licensed under the Apache-2.0 license or a
|
|
7
|
+
* compatible open source license.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/*
|
|
12
|
+
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
13
|
+
* license agreements. See the NOTICE file distributed with
|
|
14
|
+
* this work for additional information regarding copyright
|
|
15
|
+
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
16
|
+
* the Apache License, Version 2.0 (the "License"); you may
|
|
17
|
+
* not use this file except in compliance with the License.
|
|
18
|
+
* You may obtain a copy of the License at
|
|
19
|
+
*
|
|
20
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
21
|
+
*
|
|
22
|
+
* Unless required by applicable law or agreed to in writing,
|
|
23
|
+
* software distributed under the License is distributed on an
|
|
24
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
25
|
+
* KIND, either express or implied. See the License for the
|
|
26
|
+
* specific language governing permissions and limitations
|
|
27
|
+
* under the License.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
* This file was generated from OpenSearch API Spec. Do not edit it
|
|
32
|
+
* manually. If you want to make changes, either update the spec or
|
|
33
|
+
* the API generator.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
'use strict';
|
|
37
|
+
|
|
38
|
+
/* eslint camelcase: 0 */
|
|
39
|
+
/* eslint no-unused-vars: 0 */
|
|
40
|
+
|
|
41
|
+
const {
|
|
42
|
+
handleError,
|
|
43
|
+
encodePathParam,
|
|
44
|
+
normalizeArguments,
|
|
45
|
+
kConfigurationError,
|
|
46
|
+
} = require('../utils');
|
|
47
|
+
|
|
48
|
+
/** @namespace API-Transforms */
|
|
49
|
+
|
|
50
|
+
function TransformsApi(transport, ConfigurationError) {
|
|
51
|
+
this.transport = transport;
|
|
52
|
+
this[kConfigurationError] = ConfigurationError;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Returns the details of all transform jobs.
|
|
57
|
+
* <br/> See Also: {@link https://opensearch.org/docs/latest/im-plugin/index-transforms/transforms-apis/#get-a-transform-jobs-details - transforms.search}
|
|
58
|
+
*
|
|
59
|
+
* @memberOf API-Transforms
|
|
60
|
+
*
|
|
61
|
+
* @param {object} [params]
|
|
62
|
+
* @param {number} [params.size] - Specifies the number of transforms to return. Default is 10.
|
|
63
|
+
* @param {number} [params.from] - The starting transform to return. Default is 0.
|
|
64
|
+
* @param {string} [params.search] - The search term to use to filter results.
|
|
65
|
+
* @param {string} [params.sortField] - The field to sort results with.
|
|
66
|
+
* @param {string} [params.sortDirection] - Specifies the direction to sort results in. Can be ASC or DESC. Default is ASC.
|
|
67
|
+
*
|
|
68
|
+
* @param {TransportRequestOptions} [options] - Options for {@link Transport#request}
|
|
69
|
+
* @param {function} [callback] - Callback that handles errors and response
|
|
70
|
+
*
|
|
71
|
+
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
|
|
72
|
+
*/
|
|
73
|
+
TransformsApi.prototype.search = function (params, options, callback) {
|
|
74
|
+
[params, options, callback] = normalizeArguments(params, options, callback);
|
|
75
|
+
|
|
76
|
+
let { method, body, ...querystring } = params;
|
|
77
|
+
|
|
78
|
+
let path = ['_plugins', '_transform'].filter((c) => c != null).join('/');
|
|
79
|
+
method = 'GET';
|
|
80
|
+
body = body || '';
|
|
81
|
+
|
|
82
|
+
return this.transport.request({ method, path, querystring, body }, options, callback);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Returns a preview of what a transformed index would look like.
|
|
87
|
+
* <br/> See Also: {@link https://opensearch.org/docs/latest/im-plugin/index-transforms/transforms-apis/#preview-a-transform-jobs-results - transforms.preview}
|
|
88
|
+
*
|
|
89
|
+
* @memberOf API-Transforms
|
|
90
|
+
*
|
|
91
|
+
* @param {object} [params] - (Unused)
|
|
92
|
+
* @param {TransportRequestOptions} [options] - Options for {@link Transport#request}
|
|
93
|
+
* @param {function} [callback] - Callback that handles errors and response
|
|
94
|
+
*
|
|
95
|
+
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
|
|
96
|
+
*/
|
|
97
|
+
TransformsApi.prototype.preview = function (params, options, callback) {
|
|
98
|
+
[params, options, callback] = normalizeArguments(params, options, callback);
|
|
99
|
+
|
|
100
|
+
let { method, body, ...querystring } = params;
|
|
101
|
+
|
|
102
|
+
let path = ['_plugins', '_transform', '_preview'].filter((c) => c != null).join('/');
|
|
103
|
+
method = 'GET';
|
|
104
|
+
body = body || '';
|
|
105
|
+
|
|
106
|
+
return this.transport.request({ method, path, querystring, body }, options, callback);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Delete an index transform.
|
|
111
|
+
* <br/> See Also: {@link https://opensearch.org/docs/latest/im-plugin/index-transforms/transforms-apis/#delete-a-transform-job - transforms.delete}
|
|
112
|
+
*
|
|
113
|
+
* @memberOf API-Transforms
|
|
114
|
+
*
|
|
115
|
+
* @param {object} params
|
|
116
|
+
* @param {string} params.id - Transform to delete
|
|
117
|
+
*
|
|
118
|
+
* @param {TransportRequestOptions} [options] - Options for {@link Transport#request}
|
|
119
|
+
* @param {function} [callback] - Callback that handles errors and response
|
|
120
|
+
*
|
|
121
|
+
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
|
|
122
|
+
*/
|
|
123
|
+
TransformsApi.prototype.delete = function (params, options, callback) {
|
|
124
|
+
[params, options, callback] = normalizeArguments(params, options, callback);
|
|
125
|
+
|
|
126
|
+
if (params.id == null) {
|
|
127
|
+
const err = new this[kConfigurationError]('Missing required parameter: id');
|
|
128
|
+
return handleError(err, callback);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
let { method, body, id, ...querystring } = params;
|
|
132
|
+
id = encodePathParam(id);
|
|
133
|
+
|
|
134
|
+
let path = ['_plugins', '_transform', id].filter((c) => c != null).join('/');
|
|
135
|
+
method = 'DELETE';
|
|
136
|
+
body = body || '';
|
|
137
|
+
|
|
138
|
+
return this.transport.request({ method, path, querystring, body }, options, callback);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Returns the status and metadata of a transform job.
|
|
143
|
+
* <br/> See Also: {@link https://opensearch.org/docs/latest/im-plugin/index-transforms/transforms-apis/#get-a-transform-jobs-details - transforms.get}
|
|
144
|
+
*
|
|
145
|
+
* @memberOf API-Transforms
|
|
146
|
+
*
|
|
147
|
+
* @param {object} params
|
|
148
|
+
* @param {string} params.id - Transform to access
|
|
149
|
+
*
|
|
150
|
+
* @param {TransportRequestOptions} [options] - Options for {@link Transport#request}
|
|
151
|
+
* @param {function} [callback] - Callback that handles errors and response
|
|
152
|
+
*
|
|
153
|
+
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
|
|
154
|
+
*/
|
|
155
|
+
TransformsApi.prototype.get = function (params, options, callback) {
|
|
156
|
+
[params, options, callback] = normalizeArguments(params, options, callback);
|
|
157
|
+
|
|
158
|
+
if (params.id == null) {
|
|
159
|
+
const err = new this[kConfigurationError]('Missing required parameter: id');
|
|
160
|
+
return handleError(err, callback);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
let { method, body, id, ...querystring } = params;
|
|
164
|
+
id = encodePathParam(id);
|
|
165
|
+
|
|
166
|
+
let path = ['_plugins', '_transform', id].filter((c) => c != null).join('/');
|
|
167
|
+
method = 'GET';
|
|
168
|
+
body = body || '';
|
|
169
|
+
|
|
170
|
+
return this.transport.request({ method, path, querystring, body }, options, callback);
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Create an index transform, or update a transform if if_seq_no and if_primary_term are provided.
|
|
175
|
+
* <br/> See Also: {@link https://opensearch.org/docs/latest/im-plugin/index-transforms/transforms-apis/#create-a-transform-job - transforms.put}
|
|
176
|
+
*
|
|
177
|
+
* @memberOf API-Transforms
|
|
178
|
+
*
|
|
179
|
+
* @param {object} params
|
|
180
|
+
* @param {number} [params.if_seq_no] - Only perform the operation if the document has this sequence number.
|
|
181
|
+
* @param {number} [params.if_primary_term] - Only perform the operation if the document has this primary term.
|
|
182
|
+
* @param {string} params.id - Transform to create/update
|
|
183
|
+
* @param {object} [params.body]
|
|
184
|
+
*
|
|
185
|
+
* @param {TransportRequestOptions} [options] - Options for {@link Transport#request}
|
|
186
|
+
* @param {function} [callback] - Callback that handles errors and response
|
|
187
|
+
*
|
|
188
|
+
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
|
|
189
|
+
*/
|
|
190
|
+
TransformsApi.prototype.put = function (params, options, callback) {
|
|
191
|
+
[params, options, callback] = normalizeArguments(params, options, callback);
|
|
192
|
+
|
|
193
|
+
if (params.id == null) {
|
|
194
|
+
const err = new this[kConfigurationError]('Missing required parameter: id');
|
|
195
|
+
return handleError(err, callback);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
let { method, body, id, ...querystring } = params;
|
|
199
|
+
id = encodePathParam(id);
|
|
200
|
+
|
|
201
|
+
let path = ['_plugins', '_transform', id].filter((c) => c != null).join('/');
|
|
202
|
+
method = 'PUT';
|
|
203
|
+
body = body || '';
|
|
204
|
+
|
|
205
|
+
return this.transport.request({ method, path, querystring, body }, options, callback);
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Returns the status and metadata of a transform job.
|
|
210
|
+
* <br/> See Also: {@link https://opensearch.org/docs/latest/im-plugin/index-transforms/transforms-apis/#get-the-status-of-a-transform-job - transforms.explain}
|
|
211
|
+
*
|
|
212
|
+
* @memberOf API-Transforms
|
|
213
|
+
*
|
|
214
|
+
* @param {object} params
|
|
215
|
+
* @param {string} params.id - Transform to explain
|
|
216
|
+
*
|
|
217
|
+
* @param {TransportRequestOptions} [options] - Options for {@link Transport#request}
|
|
218
|
+
* @param {function} [callback] - Callback that handles errors and response
|
|
219
|
+
*
|
|
220
|
+
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
|
|
221
|
+
*/
|
|
222
|
+
TransformsApi.prototype.explain = function (params, options, callback) {
|
|
223
|
+
[params, options, callback] = normalizeArguments(params, options, callback);
|
|
224
|
+
|
|
225
|
+
if (params.id == null) {
|
|
226
|
+
const err = new this[kConfigurationError]('Missing required parameter: id');
|
|
227
|
+
return handleError(err, callback);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
let { method, body, id, ...querystring } = params;
|
|
231
|
+
id = encodePathParam(id);
|
|
232
|
+
|
|
233
|
+
let path = ['_plugins', '_transform', id, '_explain'].filter((c) => c != null).join('/');
|
|
234
|
+
method = 'GET';
|
|
235
|
+
body = body || '';
|
|
236
|
+
|
|
237
|
+
return this.transport.request({ method, path, querystring, body }, options, callback);
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Start transform.
|
|
242
|
+
* <br/> See Also: {@link https://opensearch.org/docs/latest/im-plugin/index-transforms/transforms-apis/#start-a-transform-job - transforms.start}
|
|
243
|
+
*
|
|
244
|
+
* @memberOf API-Transforms
|
|
245
|
+
*
|
|
246
|
+
* @param {object} params
|
|
247
|
+
* @param {string} params.id - Transform to start
|
|
248
|
+
*
|
|
249
|
+
* @param {TransportRequestOptions} [options] - Options for {@link Transport#request}
|
|
250
|
+
* @param {function} [callback] - Callback that handles errors and response
|
|
251
|
+
*
|
|
252
|
+
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
|
|
253
|
+
*/
|
|
254
|
+
TransformsApi.prototype.start = function (params, options, callback) {
|
|
255
|
+
[params, options, callback] = normalizeArguments(params, options, callback);
|
|
256
|
+
|
|
257
|
+
if (params.id == null) {
|
|
258
|
+
const err = new this[kConfigurationError]('Missing required parameter: id');
|
|
259
|
+
return handleError(err, callback);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
let { method, body, id, ...querystring } = params;
|
|
263
|
+
id = encodePathParam(id);
|
|
264
|
+
|
|
265
|
+
let path = ['_plugins', '_transform', id, '_start'].filter((c) => c != null).join('/');
|
|
266
|
+
method = 'POST';
|
|
267
|
+
body = body || '';
|
|
268
|
+
|
|
269
|
+
return this.transport.request({ method, path, querystring, body }, options, callback);
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* stop transform.
|
|
274
|
+
* <br/> See Also: {@link https://opensearch.org/docs/latest/im-plugin/index-transforms/transforms-apis/#stop-a-transform-job - transforms.stop}
|
|
275
|
+
*
|
|
276
|
+
* @memberOf API-Transforms
|
|
277
|
+
*
|
|
278
|
+
* @param {object} params
|
|
279
|
+
* @param {string} params.id - Transform to stop
|
|
280
|
+
*
|
|
281
|
+
* @param {TransportRequestOptions} [options] - Options for {@link Transport#request}
|
|
282
|
+
* @param {function} [callback] - Callback that handles errors and response
|
|
283
|
+
*
|
|
284
|
+
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
|
|
285
|
+
*/
|
|
286
|
+
TransformsApi.prototype.stop = function (params, options, callback) {
|
|
287
|
+
[params, options, callback] = normalizeArguments(params, options, callback);
|
|
288
|
+
|
|
289
|
+
if (params.id == null) {
|
|
290
|
+
const err = new this[kConfigurationError]('Missing required parameter: id');
|
|
291
|
+
return handleError(err, callback);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
let { method, body, id, ...querystring } = params;
|
|
295
|
+
id = encodePathParam(id);
|
|
296
|
+
|
|
297
|
+
let path = ['_plugins', '_transform', id, '_stop'].filter((c) => c != null).join('/');
|
|
298
|
+
method = 'POST';
|
|
299
|
+
body = body || '';
|
|
300
|
+
|
|
301
|
+
return this.transport.request({ method, path, querystring, body }, options, callback);
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
module.exports = TransformsApi;
|
package/api/index.js
CHANGED
|
@@ -70,6 +70,7 @@ const rankEvalApi = require('./api/rank_eval');
|
|
|
70
70
|
const reindexApi = require('./api/reindex');
|
|
71
71
|
const reindexRethrottleApi = require('./api/reindex_rethrottle');
|
|
72
72
|
const renderSearchTemplateApi = require('./api/render_search_template');
|
|
73
|
+
const RollupsApi = require('./api/rollups');
|
|
73
74
|
const scriptsPainlessExecuteApi = require('./api/scripts_painless_execute');
|
|
74
75
|
const scrollApi = require('./api/scroll');
|
|
75
76
|
const SecurityApi = require('./api/security');
|
|
@@ -81,6 +82,7 @@ const SnapshotApi = require('./api/snapshot');
|
|
|
81
82
|
const TasksApi = require('./api/tasks');
|
|
82
83
|
const termsEnumApi = require('./api/terms_enum');
|
|
83
84
|
const termvectorsApi = require('./api/termvectors');
|
|
85
|
+
const TransformsAPi = require('./api/transforms');
|
|
84
86
|
const updateApi = require('./api/update');
|
|
85
87
|
const updateByQueryApi = require('./api/update_by_query');
|
|
86
88
|
const updateByQueryRethrottleApi = require('./api/update_by_query_rethrottle');
|
|
@@ -94,10 +96,12 @@ const kHttp = Symbol('Http');
|
|
|
94
96
|
const kIndices = Symbol('Indices');
|
|
95
97
|
const kIngest = Symbol('Ingest');
|
|
96
98
|
const kNodes = Symbol('Nodes');
|
|
99
|
+
const kRollups = Symbol('Rollups');
|
|
97
100
|
const kSecurity = Symbol('Security');
|
|
98
101
|
const kShutdown = Symbol('Shutdown');
|
|
99
102
|
const kSnapshot = Symbol('Snapshot');
|
|
100
103
|
const kTasks = Symbol('Tasks');
|
|
104
|
+
const kTransforms = Symbol('Transforms');
|
|
101
105
|
|
|
102
106
|
function OpenSearchAPI(opts) {
|
|
103
107
|
this[kConfigurationError] = opts.ConfigurationError;
|
|
@@ -109,10 +113,12 @@ function OpenSearchAPI(opts) {
|
|
|
109
113
|
this[kIndices] = null;
|
|
110
114
|
this[kIngest] = null;
|
|
111
115
|
this[kNodes] = null;
|
|
116
|
+
this[kRollups] = null;
|
|
112
117
|
this[kSecurity] = null;
|
|
113
118
|
this[kShutdown] = null;
|
|
114
119
|
this[kSnapshot] = null;
|
|
115
120
|
this[kTasks] = null;
|
|
121
|
+
this[kTransforms] = null;
|
|
116
122
|
}
|
|
117
123
|
|
|
118
124
|
OpenSearchAPI.prototype.bulk = bulkApi;
|
|
@@ -324,6 +330,14 @@ Object.defineProperties(OpenSearchAPI.prototype, {
|
|
|
324
330
|
return this.renderSearchTemplate;
|
|
325
331
|
},
|
|
326
332
|
},
|
|
333
|
+
rollups: {
|
|
334
|
+
get() {
|
|
335
|
+
if (this[kRollups] === null) {
|
|
336
|
+
this[kRollups] = new RollupsApi(this.transport, this[kConfigurationError]);
|
|
337
|
+
}
|
|
338
|
+
return this[kRollups];
|
|
339
|
+
},
|
|
340
|
+
},
|
|
327
341
|
scripts_painless_execute: {
|
|
328
342
|
get() {
|
|
329
343
|
return this.scriptsPainlessExecute;
|
|
@@ -376,6 +390,14 @@ Object.defineProperties(OpenSearchAPI.prototype, {
|
|
|
376
390
|
return this.termsEnum;
|
|
377
391
|
},
|
|
378
392
|
},
|
|
393
|
+
transforms: {
|
|
394
|
+
get() {
|
|
395
|
+
if (this[kTransforms] === null) {
|
|
396
|
+
this[kTransforms] = new TransformsAPi(this.transport, this[kConfigurationError]);
|
|
397
|
+
}
|
|
398
|
+
return this[kTransforms];
|
|
399
|
+
},
|
|
400
|
+
},
|
|
379
401
|
update_by_query: {
|
|
380
402
|
get() {
|
|
381
403
|
return this.updateByQuery;
|
package/index.d.ts
CHANGED
|
@@ -4621,6 +4621,104 @@ declare class Client {
|
|
|
4621
4621
|
options: TransportRequestOptions,
|
|
4622
4622
|
callback: callbackFn<TResponse, TContext>
|
|
4623
4623
|
): TransportRequestCallback;
|
|
4624
|
+
rollups: {
|
|
4625
|
+
delete<TResponse = Record<string, any>, TContext = Context>(
|
|
4626
|
+
params?: Record<string, any>,
|
|
4627
|
+
options?: TransportRequestOptions
|
|
4628
|
+
): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
|
|
4629
|
+
delete<TResponse = Record<string, any>, TContext = Context>(
|
|
4630
|
+
callback: callbackFn<TResponse, TContext>
|
|
4631
|
+
): TransportRequestCallback;
|
|
4632
|
+
delete<TResponse = Record<string, any>, TContext = Context>(
|
|
4633
|
+
params: Record<string, any>,
|
|
4634
|
+
callback: callbackFn<TResponse, TContext>
|
|
4635
|
+
): TransportRequestCallback;
|
|
4636
|
+
delete<TResponse = Record<string, any>, TContext = Context>(
|
|
4637
|
+
params: Record<string, any>,
|
|
4638
|
+
options: TransportRequestOptions,
|
|
4639
|
+
callback: callbackFn<TResponse, TContext>
|
|
4640
|
+
): TransportRequestCallback;
|
|
4641
|
+
get<TResponse = Record<string, any>, TContext = Context>(
|
|
4642
|
+
params?: Record<string, any>,
|
|
4643
|
+
options?: TransportRequestOptions
|
|
4644
|
+
): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
|
|
4645
|
+
get<TResponse = Record<string, any>, TContext = Context>(
|
|
4646
|
+
callback: callbackFn<TResponse, TContext>
|
|
4647
|
+
): TransportRequestCallback;
|
|
4648
|
+
get<TResponse = Record<string, any>, TContext = Context>(
|
|
4649
|
+
params: Record<string, any>,
|
|
4650
|
+
callback: callbackFn<TResponse, TContext>
|
|
4651
|
+
): TransportRequestCallback;
|
|
4652
|
+
get<TResponse = Record<string, any>, TContext = Context>(
|
|
4653
|
+
params: Record<string, any>,
|
|
4654
|
+
options: TransportRequestOptions,
|
|
4655
|
+
callback: callbackFn<TResponse, TContext>
|
|
4656
|
+
): TransportRequestCallback;
|
|
4657
|
+
put<TResponse = Record<string, any>, TContext = Context>(
|
|
4658
|
+
params?: Record<string, any>,
|
|
4659
|
+
options?: TransportRequestOptions
|
|
4660
|
+
): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
|
|
4661
|
+
put<TResponse = Record<string, any>, TContext = Context>(
|
|
4662
|
+
callback: callbackFn<TResponse, TContext>
|
|
4663
|
+
): TransportRequestCallback;
|
|
4664
|
+
put<TResponse = Record<string, any>, TContext = Context>(
|
|
4665
|
+
params: Record<string, any>,
|
|
4666
|
+
callback: callbackFn<TResponse, TContext>
|
|
4667
|
+
): TransportRequestCallback;
|
|
4668
|
+
put<TResponse = Record<string, any>, TContext = Context>(
|
|
4669
|
+
params: Record<string, any>,
|
|
4670
|
+
options: TransportRequestOptions,
|
|
4671
|
+
callback: callbackFn<TResponse, TContext>
|
|
4672
|
+
): TransportRequestCallback;
|
|
4673
|
+
explain<TResponse = Record<string, any>, TContext = Context>(
|
|
4674
|
+
params?: Record<string, any>,
|
|
4675
|
+
options?: TransportRequestOptions
|
|
4676
|
+
): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
|
|
4677
|
+
explain<TResponse = Record<string, any>, TContext = Context>(
|
|
4678
|
+
callback: callbackFn<TResponse, TContext>
|
|
4679
|
+
): TransportRequestCallback;
|
|
4680
|
+
explain<TResponse = Record<string, any>, TContext = Context>(
|
|
4681
|
+
params: Record<string, any>,
|
|
4682
|
+
callback: callbackFn<TResponse, TContext>
|
|
4683
|
+
): TransportRequestCallback;
|
|
4684
|
+
explain<TResponse = Record<string, any>, TContext = Context>(
|
|
4685
|
+
params: Record<string, any>,
|
|
4686
|
+
options: TransportRequestOptions,
|
|
4687
|
+
callback: callbackFn<TResponse, TContext>
|
|
4688
|
+
): TransportRequestCallback;
|
|
4689
|
+
start<TResponse = Record<string, any>, TContext = Context>(
|
|
4690
|
+
params?: Record<string, any>,
|
|
4691
|
+
options?: TransportRequestOptions
|
|
4692
|
+
): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
|
|
4693
|
+
start<TResponse = Record<string, any>, TContext = Context>(
|
|
4694
|
+
callback: callbackFn<TResponse, TContext>
|
|
4695
|
+
): TransportRequestCallback;
|
|
4696
|
+
start<TResponse = Record<string, any>, TContext = Context>(
|
|
4697
|
+
params: Record<string, any>,
|
|
4698
|
+
callback: callbackFn<TResponse, TContext>
|
|
4699
|
+
): TransportRequestCallback;
|
|
4700
|
+
start<TResponse = Record<string, any>, TContext = Context>(
|
|
4701
|
+
params: Record<string, any>,
|
|
4702
|
+
options: TransportRequestOptions,
|
|
4703
|
+
callback: callbackFn<TResponse, TContext>
|
|
4704
|
+
): TransportRequestCallback;
|
|
4705
|
+
stop<TResponse = Record<string, any>, TContext = Context>(
|
|
4706
|
+
params?: Record<string, any>,
|
|
4707
|
+
options?: TransportRequestOptions
|
|
4708
|
+
): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
|
|
4709
|
+
stop<TResponse = Record<string, any>, TContext = Context>(
|
|
4710
|
+
callback: callbackFn<TResponse, TContext>
|
|
4711
|
+
): TransportRequestCallback;
|
|
4712
|
+
stop<TResponse = Record<string, any>, TContext = Context>(
|
|
4713
|
+
params: Record<string, any>,
|
|
4714
|
+
callback: callbackFn<TResponse, TContext>
|
|
4715
|
+
): TransportRequestCallback;
|
|
4716
|
+
stop<TResponse = Record<string, any>, TContext = Context>(
|
|
4717
|
+
params: Record<string, any>,
|
|
4718
|
+
options: TransportRequestOptions,
|
|
4719
|
+
callback: callbackFn<TResponse, TContext>
|
|
4720
|
+
): TransportRequestCallback;
|
|
4721
|
+
};
|
|
4624
4722
|
scripts_painless_execute<
|
|
4625
4723
|
TResponse = Record<string, any>,
|
|
4626
4724
|
TRequestBody extends RequestBody = Record<string, any>,
|
|
@@ -5473,6 +5571,136 @@ declare class Client {
|
|
|
5473
5571
|
options: TransportRequestOptions,
|
|
5474
5572
|
callback: callbackFn<TResponse, TContext>
|
|
5475
5573
|
): TransportRequestCallback;
|
|
5574
|
+
transforms: {
|
|
5575
|
+
search<TResponse = Record<string, any>, TContext = Context>(
|
|
5576
|
+
params?: Record<string, any>,
|
|
5577
|
+
options?: TransportRequestOptions
|
|
5578
|
+
): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
|
|
5579
|
+
search<TResponse = Record<string, any>, TContext = Context>(
|
|
5580
|
+
callback: callbackFn<TResponse, TContext>
|
|
5581
|
+
): TransportRequestCallback;
|
|
5582
|
+
search<TResponse = Record<string, any>, TContext = Context>(
|
|
5583
|
+
params: Record<string, any>,
|
|
5584
|
+
callback: callbackFn<TResponse, TContext>
|
|
5585
|
+
): TransportRequestCallback;
|
|
5586
|
+
search<TResponse = Record<string, any>, TContext = Context>(
|
|
5587
|
+
params: Record<string, any>,
|
|
5588
|
+
options: TransportRequestOptions,
|
|
5589
|
+
callback: callbackFn<TResponse, TContext>
|
|
5590
|
+
): TransportRequestCallback;
|
|
5591
|
+
preview<TResponse = Record<string, any>, TContext = Context>(
|
|
5592
|
+
params?: Record<string, any>,
|
|
5593
|
+
options?: TransportRequestOptions
|
|
5594
|
+
): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
|
|
5595
|
+
preview<TResponse = Record<string, any>, TContext = Context>(
|
|
5596
|
+
callback: callbackFn<TResponse, TContext>
|
|
5597
|
+
): TransportRequestCallback;
|
|
5598
|
+
preview<TResponse = Record<string, any>, TContext = Context>(
|
|
5599
|
+
params: Record<string, any>,
|
|
5600
|
+
callback: callbackFn<TResponse, TContext>
|
|
5601
|
+
): TransportRequestCallback;
|
|
5602
|
+
preview<TResponse = Record<string, any>, TContext = Context>(
|
|
5603
|
+
params: Record<string, any>,
|
|
5604
|
+
options: TransportRequestOptions,
|
|
5605
|
+
callback: callbackFn<TResponse, TContext>
|
|
5606
|
+
): TransportRequestCallback;
|
|
5607
|
+
delete<TResponse = Record<string, any>, TContext = Context>(
|
|
5608
|
+
params?: Record<string, any>,
|
|
5609
|
+
options?: TransportRequestOptions
|
|
5610
|
+
): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
|
|
5611
|
+
delete<TResponse = Record<string, any>, TContext = Context>(
|
|
5612
|
+
callback: callbackFn<TResponse, TContext>
|
|
5613
|
+
): TransportRequestCallback;
|
|
5614
|
+
delete<TResponse = Record<string, any>, TContext = Context>(
|
|
5615
|
+
params: Record<string, any>,
|
|
5616
|
+
callback: callbackFn<TResponse, TContext>
|
|
5617
|
+
): TransportRequestCallback;
|
|
5618
|
+
delete<TResponse = Record<string, any>, TContext = Context>(
|
|
5619
|
+
params: Record<string, any>,
|
|
5620
|
+
options: TransportRequestOptions,
|
|
5621
|
+
callback: callbackFn<TResponse, TContext>
|
|
5622
|
+
): TransportRequestCallback;
|
|
5623
|
+
get<TResponse = Record<string, any>, TContext = Context>(
|
|
5624
|
+
params?: Record<string, any>,
|
|
5625
|
+
options?: TransportRequestOptions
|
|
5626
|
+
): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
|
|
5627
|
+
get<TResponse = Record<string, any>, TContext = Context>(
|
|
5628
|
+
callback: callbackFn<TResponse, TContext>
|
|
5629
|
+
): TransportRequestCallback;
|
|
5630
|
+
get<TResponse = Record<string, any>, TContext = Context>(
|
|
5631
|
+
params: Record<string, any>,
|
|
5632
|
+
callback: callbackFn<TResponse, TContext>
|
|
5633
|
+
): TransportRequestCallback;
|
|
5634
|
+
get<TResponse = Record<string, any>, TContext = Context>(
|
|
5635
|
+
params: Record<string, any>,
|
|
5636
|
+
options: TransportRequestOptions,
|
|
5637
|
+
callback: callbackFn<TResponse, TContext>
|
|
5638
|
+
): TransportRequestCallback;
|
|
5639
|
+
put<TResponse = Record<string, any>, TContext = Context>(
|
|
5640
|
+
params?: Record<string, any>,
|
|
5641
|
+
options?: TransportRequestOptions
|
|
5642
|
+
): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
|
|
5643
|
+
put<TResponse = Record<string, any>, TContext = Context>(
|
|
5644
|
+
callback: callbackFn<TResponse, TContext>
|
|
5645
|
+
): TransportRequestCallback;
|
|
5646
|
+
put<TResponse = Record<string, any>, TContext = Context>(
|
|
5647
|
+
params: Record<string, any>,
|
|
5648
|
+
callback: callbackFn<TResponse, TContext>
|
|
5649
|
+
): TransportRequestCallback;
|
|
5650
|
+
put<TResponse = Record<string, any>, TContext = Context>(
|
|
5651
|
+
params: Record<string, any>,
|
|
5652
|
+
options: TransportRequestOptions,
|
|
5653
|
+
callback: callbackFn<TResponse, TContext>
|
|
5654
|
+
): TransportRequestCallback;
|
|
5655
|
+
explain<TResponse = Record<string, any>, TContext = Context>(
|
|
5656
|
+
params?: Record<string, any>,
|
|
5657
|
+
options?: TransportRequestOptions
|
|
5658
|
+
): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
|
|
5659
|
+
explain<TResponse = Record<string, any>, TContext = Context>(
|
|
5660
|
+
callback: callbackFn<TResponse, TContext>
|
|
5661
|
+
): TransportRequestCallback;
|
|
5662
|
+
explain<TResponse = Record<string, any>, TContext = Context>(
|
|
5663
|
+
params: Record<string, any>,
|
|
5664
|
+
callback: callbackFn<TResponse, TContext>
|
|
5665
|
+
): TransportRequestCallback;
|
|
5666
|
+
explain<TResponse = Record<string, any>, TContext = Context>(
|
|
5667
|
+
params: Record<string, any>,
|
|
5668
|
+
options: TransportRequestOptions,
|
|
5669
|
+
callback: callbackFn<TResponse, TContext>
|
|
5670
|
+
): TransportRequestCallback;
|
|
5671
|
+
start<TResponse = Record<string, any>, TContext = Context>(
|
|
5672
|
+
params?: Record<string, any>,
|
|
5673
|
+
options?: TransportRequestOptions
|
|
5674
|
+
): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
|
|
5675
|
+
start<TResponse = Record<string, any>, TContext = Context>(
|
|
5676
|
+
callback: callbackFn<TResponse, TContext>
|
|
5677
|
+
): TransportRequestCallback;
|
|
5678
|
+
start<TResponse = Record<string, any>, TContext = Context>(
|
|
5679
|
+
params: Record<string, any>,
|
|
5680
|
+
callback: callbackFn<TResponse, TContext>
|
|
5681
|
+
): TransportRequestCallback;
|
|
5682
|
+
start<TResponse = Record<string, any>, TContext = Context>(
|
|
5683
|
+
params: Record<string, any>,
|
|
5684
|
+
options: TransportRequestOptions,
|
|
5685
|
+
callback: callbackFn<TResponse, TContext>
|
|
5686
|
+
): TransportRequestCallback;
|
|
5687
|
+
stop<TResponse = Record<string, any>, TContext = Context>(
|
|
5688
|
+
params?: Record<string, any>,
|
|
5689
|
+
options?: TransportRequestOptions
|
|
5690
|
+
): TransportRequestPromise<ApiResponse<TResponse, TContext>>;
|
|
5691
|
+
stop<TResponse = Record<string, any>, TContext = Context>(
|
|
5692
|
+
callback: callbackFn<TResponse, TContext>
|
|
5693
|
+
): TransportRequestCallback;
|
|
5694
|
+
stop<TResponse = Record<string, any>, TContext = Context>(
|
|
5695
|
+
params: Record<string, any>,
|
|
5696
|
+
callback: callbackFn<TResponse, TContext>
|
|
5697
|
+
): TransportRequestCallback;
|
|
5698
|
+
stop<TResponse = Record<string, any>, TContext = Context>(
|
|
5699
|
+
params: Record<string, any>,
|
|
5700
|
+
options: TransportRequestOptions,
|
|
5701
|
+
callback: callbackFn<TResponse, TContext>
|
|
5702
|
+
): TransportRequestCallback;
|
|
5703
|
+
};
|
|
5476
5704
|
update<
|
|
5477
5705
|
TResponse = Record<string, any>,
|
|
5478
5706
|
TRequestBody extends RequestBody = Record<string, any>,
|
package/lib/aws/shared.js
CHANGED
|
@@ -13,9 +13,12 @@ const Connection = require('../Connection');
|
|
|
13
13
|
const Transport = require('../Transport');
|
|
14
14
|
const aws4 = require('aws4');
|
|
15
15
|
const AwsSigv4SignerError = require('./errors');
|
|
16
|
+
const { RequestAbortedError } = require('../errors');
|
|
16
17
|
const crypto = require('crypto');
|
|
17
18
|
const { toMs } = Transport.internals;
|
|
18
19
|
|
|
20
|
+
const noop = () => {};
|
|
21
|
+
|
|
19
22
|
function giveAwsCredentialProviderLoader(getAwsSDKCredentialsProvider) {
|
|
20
23
|
return function loadAwsCredentialProvider() {
|
|
21
24
|
return new Promise((resolve, reject) => {
|
|
@@ -118,45 +121,88 @@ function giveAwsV4Signer(awsDefaultCredentialsProvider) {
|
|
|
118
121
|
}
|
|
119
122
|
|
|
120
123
|
if (!expired) {
|
|
121
|
-
if (
|
|
124
|
+
if (callback === undefined) {
|
|
122
125
|
return super.request(params, options);
|
|
126
|
+
} else {
|
|
127
|
+
return super.request(params, options, callback);
|
|
123
128
|
}
|
|
124
|
-
super.request(params, options, callback);
|
|
125
|
-
return;
|
|
126
129
|
}
|
|
127
130
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
131
|
+
let p = null;
|
|
132
|
+
|
|
133
|
+
// promises support
|
|
134
|
+
if (callback === undefined) {
|
|
135
|
+
let onFulfilled = null;
|
|
136
|
+
let onRejected = null;
|
|
137
|
+
p = new Promise((resolve, reject) => {
|
|
138
|
+
onFulfilled = resolve;
|
|
139
|
+
onRejected = reject;
|
|
140
|
+
});
|
|
141
|
+
callback = function callback(err, result) {
|
|
142
|
+
err ? onRejected(err) : onFulfilled(result);
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const meta = {
|
|
147
|
+
aborted: false,
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
let request = { abort: noop };
|
|
151
|
+
|
|
152
|
+
const transportReturn = {
|
|
153
|
+
then(onFulfilled, onRejected) {
|
|
154
|
+
if (p != null) {
|
|
155
|
+
return p.then(onFulfilled, onRejected);
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
catch(onRejected) {
|
|
159
|
+
if (p != null) {
|
|
160
|
+
return p.catch(onRejected);
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
abort() {
|
|
164
|
+
meta.aborted = true;
|
|
165
|
+
request.abort();
|
|
166
|
+
return this;
|
|
167
|
+
},
|
|
168
|
+
finally(onFinally) {
|
|
169
|
+
if (p != null) {
|
|
170
|
+
return p.finally(onFinally);
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const makeRequest = () => {
|
|
176
|
+
// In AWS SDK V2 Credentials.refreshPromise should be available.
|
|
177
|
+
if (currentCredentials && typeof currentCredentials.refreshPromise === 'function') {
|
|
135
178
|
currentCredentials
|
|
136
179
|
.refreshPromise()
|
|
137
180
|
.then(() => {
|
|
138
|
-
|
|
181
|
+
if (meta.aborted) {
|
|
182
|
+
return callback(new RequestAbortedError());
|
|
183
|
+
}
|
|
184
|
+
request = super.request(params, options, callback);
|
|
139
185
|
})
|
|
140
186
|
.catch(callback);
|
|
141
|
-
return;
|
|
142
187
|
}
|
|
143
|
-
|
|
188
|
+
// For AWS SDK V3.
|
|
189
|
+
else {
|
|
190
|
+
opts
|
|
191
|
+
.getCredentials()
|
|
192
|
+
.then((credentials) => {
|
|
193
|
+
if (meta.aborted) {
|
|
194
|
+
return callback(new RequestAbortedError());
|
|
195
|
+
}
|
|
196
|
+
credentialsState.credentials = credentials;
|
|
197
|
+
request = super.request(params, options, callback);
|
|
198
|
+
})
|
|
199
|
+
.catch(callback);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
144
202
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
credentialsState.credentials = credentials;
|
|
149
|
-
return super.request(params, options);
|
|
150
|
-
});
|
|
151
|
-
} else {
|
|
152
|
-
opts
|
|
153
|
-
.getCredentials()
|
|
154
|
-
.then((credentials) => {
|
|
155
|
-
credentialsState.credentials = credentials;
|
|
156
|
-
super.request(params, options, callback);
|
|
157
|
-
})
|
|
158
|
-
.catch(callback);
|
|
159
|
-
}
|
|
203
|
+
makeRequest();
|
|
204
|
+
|
|
205
|
+
return transportReturn;
|
|
160
206
|
}
|
|
161
207
|
}
|
|
162
208
|
|
package/package.json
CHANGED
|
@@ -26,11 +26,14 @@
|
|
|
26
26
|
],
|
|
27
27
|
"aws": [
|
|
28
28
|
"./lib/aws/index.d.ts"
|
|
29
|
+
],
|
|
30
|
+
"aws-v3": [
|
|
31
|
+
"./lib/aws/index-v3.d.ts"
|
|
29
32
|
]
|
|
30
33
|
}
|
|
31
34
|
},
|
|
32
35
|
"homepage": "https://www.opensearch.org/",
|
|
33
|
-
"version": "2.
|
|
36
|
+
"version": "2.11.0",
|
|
34
37
|
"versionCanary": "7.10.0-canary.6",
|
|
35
38
|
"keywords": [
|
|
36
39
|
"opensearch",
|
|
@@ -75,6 +78,7 @@
|
|
|
75
78
|
"eslint": "^8.30.0",
|
|
76
79
|
"eslint-config-prettier": "^9.0.0",
|
|
77
80
|
"eslint-plugin-prettier": "^5.0.0",
|
|
81
|
+
"faker": "^6.6.6",
|
|
78
82
|
"fast-deep-equal": "^3.1.3",
|
|
79
83
|
"into-stream": "^6.0.0",
|
|
80
84
|
"js-yaml": "^4.1.0",
|
|
@@ -86,7 +90,7 @@
|
|
|
86
90
|
"prettier": "^3.0.1",
|
|
87
91
|
"pretty-hrtime": "^1.0.3",
|
|
88
92
|
"proxy": "^1.0.2",
|
|
89
|
-
"rimraf": "^
|
|
93
|
+
"rimraf": "^6.0.1",
|
|
90
94
|
"semver": "^7.3.5",
|
|
91
95
|
"simple-git": "^3.15.0",
|
|
92
96
|
"simple-statistics": "^7.7.0",
|
|
@@ -98,9 +102,9 @@
|
|
|
98
102
|
"xmlbuilder2": "^3.0.2"
|
|
99
103
|
},
|
|
100
104
|
"dependencies": {
|
|
101
|
-
"json11": "^1.0.4",
|
|
102
105
|
"aws4": "^1.11.0",
|
|
103
106
|
"debug": "^4.3.1",
|
|
107
|
+
"json11": "^1.1.2",
|
|
104
108
|
"hpagent": "^1.2.0",
|
|
105
109
|
"ms": "^2.1.3",
|
|
106
110
|
"secure-json-parse": "^2.4.0"
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*
|
|
5
|
+
* The OpenSearch Contributors require contributions made to
|
|
6
|
+
* this file be licensed under the Apache-2.0 license or a
|
|
7
|
+
* compatible open source license.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const { Client } = require('@opensearch-project/opensearch');
|
|
12
|
+
|
|
13
|
+
// Instantiate a client with basic auth as setup in the README.md file
|
|
14
|
+
const client = new Client({
|
|
15
|
+
ssl: {
|
|
16
|
+
rejectUnauthorized: false,
|
|
17
|
+
},
|
|
18
|
+
node: 'https://localhost:9200',
|
|
19
|
+
auth: {
|
|
20
|
+
username: 'admin',
|
|
21
|
+
password: 'myStrongPassword123!',
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const start = async () => {
|
|
26
|
+
const sourceIndex = 'sample-index';
|
|
27
|
+
const rollupIndex = 'rollup-index';
|
|
28
|
+
const jobId = 'my-rollup-job';
|
|
29
|
+
|
|
30
|
+
/////////////////// SETUP //////////////////
|
|
31
|
+
// Create source index
|
|
32
|
+
await client.indices.create({
|
|
33
|
+
index: sourceIndex,
|
|
34
|
+
body: {
|
|
35
|
+
mappings: {
|
|
36
|
+
properties: {
|
|
37
|
+
timestamp: { type: 'date' },
|
|
38
|
+
field1: { type: 'keyword' },
|
|
39
|
+
field2: { type: 'integer' },
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Add some documents to the index
|
|
46
|
+
const now = Date.now();
|
|
47
|
+
for (let i = 0; i < 100; i++) {
|
|
48
|
+
await client.index({
|
|
49
|
+
index: sourceIndex,
|
|
50
|
+
body: {
|
|
51
|
+
timestamp: new Date(now - i * 3600000), // Subtract 1 hour for each document
|
|
52
|
+
field1: `field1_value_${i % 10}`, // Cycle through 10 different values
|
|
53
|
+
field2: i,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Refresh the index to make sure all documents are searchable
|
|
59
|
+
await client.indices.refresh({ index: sourceIndex });
|
|
60
|
+
//////////// ROLLUP OPERATIONS ////////////
|
|
61
|
+
// Create a rollup job
|
|
62
|
+
await client.rollups.put({
|
|
63
|
+
id: jobId,
|
|
64
|
+
body: {
|
|
65
|
+
rollup: {
|
|
66
|
+
description: 'sample rollup',
|
|
67
|
+
source_index: sourceIndex,
|
|
68
|
+
target_index: rollupIndex,
|
|
69
|
+
schedule: {
|
|
70
|
+
interval: {
|
|
71
|
+
period: 1,
|
|
72
|
+
unit: 'Minutes',
|
|
73
|
+
start_time: 1602100553,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
page_size: 10,
|
|
77
|
+
delay: '0',
|
|
78
|
+
continuous: false,
|
|
79
|
+
dimensions: [
|
|
80
|
+
{
|
|
81
|
+
date_histogram: {
|
|
82
|
+
source_field: 'timestamp',
|
|
83
|
+
fixed_interval: '1440m',
|
|
84
|
+
timezone: 'UTC',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
terms: {
|
|
89
|
+
source_field: 'field1',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
metrics: [
|
|
94
|
+
{
|
|
95
|
+
source_field: 'field2',
|
|
96
|
+
metrics: [
|
|
97
|
+
{
|
|
98
|
+
avg: {},
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
max: {},
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// Start the rollup job
|
|
111
|
+
await client.rollups.start({ id: jobId });
|
|
112
|
+
|
|
113
|
+
// Check the rollup job
|
|
114
|
+
const status = await client.rollups.get({ id: jobId });
|
|
115
|
+
console.log('Running Rollup Job:');
|
|
116
|
+
console.log(status.body);
|
|
117
|
+
|
|
118
|
+
// Wait till the rollup index is created
|
|
119
|
+
while (!(await client.indices.exists({ index: rollupIndex })).body) {
|
|
120
|
+
await new Promise((resolve) => setTimeout(resolve, 5000));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Explain the rollup job
|
|
124
|
+
const explain = await client.rollups.explain({ id: jobId });
|
|
125
|
+
console.log('Rollup Job Explanation:');
|
|
126
|
+
console.log(explain.body);
|
|
127
|
+
|
|
128
|
+
// Stop the rollup job
|
|
129
|
+
await client.rollups.stop({ id: jobId });
|
|
130
|
+
|
|
131
|
+
// Delete the rollup job
|
|
132
|
+
await client.rollups.delete({ id: jobId });
|
|
133
|
+
|
|
134
|
+
///////////////// TEAR DOWN ///////////////
|
|
135
|
+
await client.indices.delete({ index: sourceIndex });
|
|
136
|
+
await client.indices.delete({ index: rollupIndex });
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
start().then(() => console.log('done'));
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*
|
|
5
|
+
* The OpenSearch Contributors require contributions made to
|
|
6
|
+
* this file be licensed under the Apache-2.0 license or a
|
|
7
|
+
* compatible open source license.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// const {Client} = require('../index.js')
|
|
12
|
+
const { Client } = require('@opensearch-project/opensearch');
|
|
13
|
+
|
|
14
|
+
const faker = require('faker');
|
|
15
|
+
|
|
16
|
+
// Instantiate a client with basic auth as setup in the README.md file
|
|
17
|
+
const client = new Client({
|
|
18
|
+
ssl: {
|
|
19
|
+
rejectUnauthorized: false,
|
|
20
|
+
},
|
|
21
|
+
node: 'https://localhost:9200',
|
|
22
|
+
auth: {
|
|
23
|
+
username: 'admin',
|
|
24
|
+
password: 'myStrongPassword123!',
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const start = async () => {
|
|
29
|
+
const sourceIndex = 'sample-index';
|
|
30
|
+
const transformIndex = 'transform-index';
|
|
31
|
+
const transformJob = 'my-transform-job';
|
|
32
|
+
|
|
33
|
+
/////////////////// SETUP //////////////////
|
|
34
|
+
// Create source index
|
|
35
|
+
await client.indices.create({
|
|
36
|
+
index: sourceIndex,
|
|
37
|
+
body: {
|
|
38
|
+
mappings: {
|
|
39
|
+
properties: {
|
|
40
|
+
name: { type: 'keyword' },
|
|
41
|
+
age: { type: 'integer' },
|
|
42
|
+
gender: { type: 'keyword' },
|
|
43
|
+
salary: { type: 'integer' },
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Create 100 documents
|
|
50
|
+
for (let i = 0; i < 100; i++) {
|
|
51
|
+
// Generate random data for each field
|
|
52
|
+
const name = faker.name.findName(); // generates a random name
|
|
53
|
+
const age = faker.datatype.number({ min: 20, max: 60 }); // generates a random age between 20 and 60
|
|
54
|
+
const gender = faker.random.arrayElement(['Male', 'Female']); // randomly selects 'Male' or 'Female'
|
|
55
|
+
const salary = faker.datatype.number({ min: 30000, max: 100000 }); // generates a random salary between 30000 and 100000
|
|
56
|
+
|
|
57
|
+
// Index the document
|
|
58
|
+
await client.index({
|
|
59
|
+
index: sourceIndex,
|
|
60
|
+
body: {
|
|
61
|
+
name,
|
|
62
|
+
age,
|
|
63
|
+
gender,
|
|
64
|
+
salary,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Refresh the index to make sure all documents are searchable
|
|
70
|
+
await client.indices.refresh({ index: sourceIndex });
|
|
71
|
+
|
|
72
|
+
//////////// TRANSFORM OPERATIONS ////////////
|
|
73
|
+
// Create transform
|
|
74
|
+
await client.transforms.put({
|
|
75
|
+
id: transformJob,
|
|
76
|
+
body: {
|
|
77
|
+
transform: {
|
|
78
|
+
enabled: true,
|
|
79
|
+
continuous: true,
|
|
80
|
+
schedule: {
|
|
81
|
+
interval: {
|
|
82
|
+
period: 1,
|
|
83
|
+
unit: 'Minutes',
|
|
84
|
+
start_time: 0
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
description: 'Sample transform job',
|
|
88
|
+
source_index: sourceIndex,
|
|
89
|
+
target_index: transformIndex,
|
|
90
|
+
data_selection_query: {
|
|
91
|
+
match_all: {}
|
|
92
|
+
},
|
|
93
|
+
page_size: 1,
|
|
94
|
+
groups: [
|
|
95
|
+
{
|
|
96
|
+
terms: {
|
|
97
|
+
source_field: 'gender',
|
|
98
|
+
target_field: 'gender'
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
terms: {
|
|
103
|
+
source_field: 'age',
|
|
104
|
+
target_field: 'age'
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
aggregations: {
|
|
109
|
+
quantity: {
|
|
110
|
+
sum: {
|
|
111
|
+
field: 'salary'
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// Start transform
|
|
120
|
+
await client.transforms.start({ id: transformJob });
|
|
121
|
+
|
|
122
|
+
// Get transform
|
|
123
|
+
const transform = await client.transforms.get({ id: transformJob });
|
|
124
|
+
console.log(transform.body);
|
|
125
|
+
|
|
126
|
+
// Wait till the transform index is created
|
|
127
|
+
while (!(await client.indices.exists({ index: transformIndex })).body) {
|
|
128
|
+
await new Promise((resolve) => setTimeout(resolve, 5000));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Get transform status
|
|
132
|
+
const explain = await client.transforms.explain({ id: transformJob });
|
|
133
|
+
console.log(explain.body);
|
|
134
|
+
|
|
135
|
+
// Stop transform
|
|
136
|
+
await client.transforms.stop({ id: transformJob });
|
|
137
|
+
|
|
138
|
+
// Delete the transform job
|
|
139
|
+
await client.transforms.delete({ id: transformJob });
|
|
140
|
+
|
|
141
|
+
///////////////// TEAR DOWN ///////////////
|
|
142
|
+
await client.indices.delete({ index: sourceIndex });
|
|
143
|
+
// await client.indices.delete({ index: transformIndex });
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
start().then(() => console.log('done'));
|