@opensearch-project/opensearch 1.1.0 → 2.1.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/.eslintignore +2 -0
- package/.eslintrc.json +31 -0
- package/.prettierrc.json +5 -0
- package/.whitesource +15 -0
- package/ADMINS.md +13 -31
- package/CHANGELOG.md +24 -0
- package/COMPATIBILITY.md +27 -0
- package/DEVELOPER_GUIDE.md +22 -5
- package/MAINTAINERS.md +15 -70
- package/Makefile +2 -12
- package/README.md +19 -123
- package/RELEASING.md +3 -3
- package/SECURITY.md +1 -1
- package/USER_GUIDE.md +197 -0
- package/api/api/bulk.js +54 -28
- package/api/api/cat.js +355 -266
- package/api/api/clear_scroll.js +18 -19
- package/api/api/cluster.js +367 -221
- package/api/api/count.js +56 -26
- package/api/api/create.js +51 -26
- package/api/api/dangling_indices.js +96 -53
- package/api/api/delete.js +50 -24
- package/api/api/delete_by_query.js +89 -27
- package/api/api/delete_by_query_rethrottle.js +34 -21
- package/api/api/delete_script.js +32 -19
- package/api/api/exists.js +56 -24
- package/api/api/exists_source.js +61 -29
- package/api/api/explain.js +61 -24
- package/api/api/features.js +57 -37
- package/api/api/field_caps.js +37 -20
- package/api/api/get.js +56 -24
- package/api/api/get_script.js +31 -19
- package/api/api/get_script_context.js +16 -17
- package/api/api/get_script_languages.js +16 -17
- package/api/api/get_source.js +56 -24
- package/api/api/index.js +61 -30
- package/api/api/indices.js +1069 -859
- package/api/api/info.js +16 -17
- package/api/api/ingest.js +133 -98
- package/api/api/mget.js +51 -28
- package/api/api/msearch.js +50 -28
- package/api/api/msearch_template.js +54 -28
- package/api/api/mtermvectors.js +49 -26
- package/api/api/nodes.js +282 -156
- package/api/api/ping.js +16 -17
- package/api/api/put_script.js +41 -27
- package/api/api/rank_eval.js +38 -22
- package/api/api/reindex.js +39 -19
- package/api/api/reindex_rethrottle.js +33 -21
- package/api/api/render_search_template.js +19 -20
- package/api/api/scripts_painless_execute.js +16 -17
- package/api/api/scroll.js +32 -19
- package/api/api/search.js +109 -26
- package/api/api/search_shards.js +37 -20
- package/api/api/search_template.js +65 -28
- package/api/api/shutdown.js +67 -56
- package/api/api/snapshot.js +348 -226
- package/api/api/tasks.js +66 -48
- package/api/api/terms_enum.js +18 -19
- package/api/api/termvectors.js +58 -28
- package/api/api/update.js +65 -26
- package/api/api/update_by_query.js +90 -25
- package/api/api/update_by_query_rethrottle.js +34 -21
- package/api/index.js +268 -181
- package/api/new.d.ts +2043 -531
- package/api/opensearch_dashboards.d.ts +240 -238
- package/api/requestParams.d.ts +302 -71
- package/api/types.d.ts +6205 -5721
- package/api/utils.js +23 -24
- package/codecov.yml +2 -2
- package/index.d.ts +5203 -1037
- package/index.js +154 -143
- package/index.mjs +10 -11
- package/jenkins/release.JenkinsFile +11 -0
- package/lib/Connection.d.ts +38 -28
- package/lib/Connection.js +166 -170
- package/lib/Helpers.d.ts +108 -68
- package/lib/Helpers.js +401 -378
- package/lib/Serializer.d.ts +3 -4
- package/lib/Serializer.js +40 -41
- package/lib/Transport.d.ts +39 -15
- package/lib/Transport.js +381 -337
- package/lib/aws/AwsSigv4Signer.js +167 -0
- package/lib/aws/errors.js +24 -0
- package/lib/aws/index.d.ts +39 -0
- package/lib/aws/index.js +19 -0
- package/lib/errors.d.ts +26 -9
- package/lib/errors.js +76 -73
- package/lib/pool/BaseConnectionPool.js +101 -99
- package/lib/pool/CloudConnectionPool.js +17 -18
- package/lib/pool/ConnectionPool.js +106 -107
- package/lib/pool/index.d.ts +9 -8
- package/lib/pool/index.js +7 -8
- package/package.json +37 -15
package/api/api/tasks.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
2
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
3
4
|
*
|
|
4
5
|
* The OpenSearch Contributors require contributions made to
|
|
5
6
|
* this file be licensed under the Apache-2.0 license or a
|
|
6
7
|
* compatible open source license.
|
|
7
8
|
*
|
|
8
|
-
* Modifications Copyright OpenSearch Contributors. See
|
|
9
|
-
* GitHub history for details.
|
|
10
9
|
*/
|
|
11
10
|
|
|
12
11
|
/*
|
|
@@ -28,33 +27,52 @@
|
|
|
28
27
|
* under the License.
|
|
29
28
|
*/
|
|
30
29
|
|
|
31
|
-
'use strict'
|
|
30
|
+
'use strict';
|
|
32
31
|
|
|
33
32
|
/* eslint camelcase: 0 */
|
|
34
33
|
/* eslint no-unused-vars: 0 */
|
|
35
34
|
|
|
36
|
-
const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
|
|
37
|
-
const acceptedQuerystring = [
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
|
|
36
|
+
const acceptedQuerystring = [
|
|
37
|
+
'nodes',
|
|
38
|
+
'actions',
|
|
39
|
+
'parent_task_id',
|
|
40
|
+
'wait_for_completion',
|
|
41
|
+
'pretty',
|
|
42
|
+
'human',
|
|
43
|
+
'error_trace',
|
|
44
|
+
'source',
|
|
45
|
+
'filter_path',
|
|
46
|
+
'timeout',
|
|
47
|
+
'detailed',
|
|
48
|
+
'group_by',
|
|
49
|
+
];
|
|
50
|
+
const snakeCase = {
|
|
51
|
+
parentTaskId: 'parent_task_id',
|
|
52
|
+
waitForCompletion: 'wait_for_completion',
|
|
53
|
+
errorTrace: 'error_trace',
|
|
54
|
+
filterPath: 'filter_path',
|
|
55
|
+
groupBy: 'group_by',
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
function TasksApi(transport, ConfigurationError) {
|
|
59
|
+
this.transport = transport;
|
|
60
|
+
this[kConfigurationError] = ConfigurationError;
|
|
43
61
|
}
|
|
44
62
|
|
|
45
|
-
TasksApi.prototype.cancel = function tasksCancelApi
|
|
46
|
-
|
|
63
|
+
TasksApi.prototype.cancel = function tasksCancelApi(params, options, callback) {
|
|
64
|
+
[params, options, callback] = normalizeArguments(params, options, callback);
|
|
47
65
|
|
|
48
|
-
let { method, body, taskId, task_id, ...querystring } = params
|
|
49
|
-
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
|
|
66
|
+
let { method, body, taskId, task_id, ...querystring } = params;
|
|
67
|
+
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
|
|
50
68
|
|
|
51
|
-
let path = ''
|
|
69
|
+
let path = '';
|
|
52
70
|
if ((task_id || taskId) != null) {
|
|
53
|
-
if (method == null) method = 'POST'
|
|
54
|
-
path = '/' + '_tasks' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_cancel'
|
|
71
|
+
if (method == null) method = 'POST';
|
|
72
|
+
path = '/' + '_tasks' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_cancel';
|
|
55
73
|
} else {
|
|
56
|
-
if (method == null) method = 'POST'
|
|
57
|
-
path = '/' + '_tasks' + '/' + '_cancel'
|
|
74
|
+
if (method == null) method = 'POST';
|
|
75
|
+
path = '/' + '_tasks' + '/' + '_cancel';
|
|
58
76
|
}
|
|
59
77
|
|
|
60
78
|
// build request object
|
|
@@ -62,58 +80,58 @@ TasksApi.prototype.cancel = function tasksCancelApi (params, options, callback)
|
|
|
62
80
|
method,
|
|
63
81
|
path,
|
|
64
82
|
body: body || '',
|
|
65
|
-
querystring
|
|
66
|
-
}
|
|
83
|
+
querystring,
|
|
84
|
+
};
|
|
67
85
|
|
|
68
|
-
return this.transport.request(request, options, callback)
|
|
69
|
-
}
|
|
86
|
+
return this.transport.request(request, options, callback);
|
|
87
|
+
};
|
|
70
88
|
|
|
71
|
-
TasksApi.prototype.get = function tasksGetApi
|
|
72
|
-
|
|
89
|
+
TasksApi.prototype.get = function tasksGetApi(params, options, callback) {
|
|
90
|
+
[params, options, callback] = normalizeArguments(params, options, callback);
|
|
73
91
|
|
|
74
92
|
// check required parameters
|
|
75
93
|
if (params.task_id == null && params.taskId == null) {
|
|
76
|
-
const err = new this[kConfigurationError]('Missing required parameter: task_id or taskId')
|
|
77
|
-
return handleError(err, callback)
|
|
94
|
+
const err = new this[kConfigurationError]('Missing required parameter: task_id or taskId');
|
|
95
|
+
return handleError(err, callback);
|
|
78
96
|
}
|
|
79
97
|
|
|
80
|
-
let { method, body, taskId, task_id, ...querystring } = params
|
|
81
|
-
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
|
|
98
|
+
let { method, body, taskId, task_id, ...querystring } = params;
|
|
99
|
+
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
|
|
82
100
|
|
|
83
|
-
let path = ''
|
|
84
|
-
if (method == null) method = 'GET'
|
|
85
|
-
path = '/' + '_tasks' + '/' + encodeURIComponent(task_id || taskId)
|
|
101
|
+
let path = '';
|
|
102
|
+
if (method == null) method = 'GET';
|
|
103
|
+
path = '/' + '_tasks' + '/' + encodeURIComponent(task_id || taskId);
|
|
86
104
|
|
|
87
105
|
// build request object
|
|
88
106
|
const request = {
|
|
89
107
|
method,
|
|
90
108
|
path,
|
|
91
109
|
body: null,
|
|
92
|
-
querystring
|
|
93
|
-
}
|
|
110
|
+
querystring,
|
|
111
|
+
};
|
|
94
112
|
|
|
95
|
-
return this.transport.request(request, options, callback)
|
|
96
|
-
}
|
|
113
|
+
return this.transport.request(request, options, callback);
|
|
114
|
+
};
|
|
97
115
|
|
|
98
|
-
TasksApi.prototype.list = function tasksListApi
|
|
99
|
-
|
|
116
|
+
TasksApi.prototype.list = function tasksListApi(params, options, callback) {
|
|
117
|
+
[params, options, callback] = normalizeArguments(params, options, callback);
|
|
100
118
|
|
|
101
|
-
let { method, body, ...querystring } = params
|
|
102
|
-
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
|
|
119
|
+
let { method, body, ...querystring } = params;
|
|
120
|
+
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
|
|
103
121
|
|
|
104
|
-
let path = ''
|
|
105
|
-
if (method == null) method = 'GET'
|
|
106
|
-
path = '/' + '_tasks'
|
|
122
|
+
let path = '';
|
|
123
|
+
if (method == null) method = 'GET';
|
|
124
|
+
path = '/' + '_tasks';
|
|
107
125
|
|
|
108
126
|
// build request object
|
|
109
127
|
const request = {
|
|
110
128
|
method,
|
|
111
129
|
path,
|
|
112
130
|
body: null,
|
|
113
|
-
querystring
|
|
114
|
-
}
|
|
131
|
+
querystring,
|
|
132
|
+
};
|
|
115
133
|
|
|
116
|
-
return this.transport.request(request, options, callback)
|
|
117
|
-
}
|
|
134
|
+
return this.transport.request(request, options, callback);
|
|
135
|
+
};
|
|
118
136
|
|
|
119
|
-
module.exports = TasksApi
|
|
137
|
+
module.exports = TasksApi;
|
package/api/api/terms_enum.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
2
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
3
4
|
*
|
|
4
5
|
* The OpenSearch Contributors require contributions made to
|
|
5
6
|
* this file be licensed under the Apache-2.0 license or a
|
|
6
7
|
* compatible open source license.
|
|
7
8
|
*
|
|
8
|
-
* Modifications Copyright OpenSearch Contributors. See
|
|
9
|
-
* GitHub history for details.
|
|
10
9
|
*/
|
|
11
10
|
|
|
12
11
|
/*
|
|
@@ -28,40 +27,40 @@
|
|
|
28
27
|
* under the License.
|
|
29
28
|
*/
|
|
30
29
|
|
|
31
|
-
'use strict'
|
|
30
|
+
'use strict';
|
|
32
31
|
|
|
33
32
|
/* eslint camelcase: 0 */
|
|
34
33
|
/* eslint no-unused-vars: 0 */
|
|
35
34
|
|
|
36
|
-
const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
|
|
37
|
-
const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path']
|
|
38
|
-
const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' }
|
|
35
|
+
const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
|
|
36
|
+
const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'];
|
|
37
|
+
const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' };
|
|
39
38
|
|
|
40
|
-
function termsEnumApi
|
|
41
|
-
|
|
39
|
+
function termsEnumApi(params, options, callback) {
|
|
40
|
+
[params, options, callback] = normalizeArguments(params, options, callback);
|
|
42
41
|
|
|
43
42
|
// check required parameters
|
|
44
43
|
if (params.index == null) {
|
|
45
|
-
const err = new this[kConfigurationError]('Missing required parameter: index')
|
|
46
|
-
return handleError(err, callback)
|
|
44
|
+
const err = new this[kConfigurationError]('Missing required parameter: index');
|
|
45
|
+
return handleError(err, callback);
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
let { method, body, index, ...querystring } = params
|
|
50
|
-
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
|
|
48
|
+
let { method, body, index, ...querystring } = params;
|
|
49
|
+
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
|
|
51
50
|
|
|
52
|
-
let path = ''
|
|
53
|
-
if (method == null) method = body == null ? 'GET' : 'POST'
|
|
54
|
-
path = '/' + encodeURIComponent(index) + '/' + '_terms_enum'
|
|
51
|
+
let path = '';
|
|
52
|
+
if (method == null) method = body == null ? 'GET' : 'POST';
|
|
53
|
+
path = '/' + encodeURIComponent(index) + '/' + '_terms_enum';
|
|
55
54
|
|
|
56
55
|
// build request object
|
|
57
56
|
const request = {
|
|
58
57
|
method,
|
|
59
58
|
path,
|
|
60
59
|
body: body || '',
|
|
61
|
-
querystring
|
|
62
|
-
}
|
|
60
|
+
querystring,
|
|
61
|
+
};
|
|
63
62
|
|
|
64
|
-
return this.transport.request(request, options, callback)
|
|
63
|
+
return this.transport.request(request, options, callback);
|
|
65
64
|
}
|
|
66
65
|
|
|
67
|
-
module.exports = termsEnumApi
|
|
66
|
+
module.exports = termsEnumApi;
|
package/api/api/termvectors.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
2
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
3
4
|
*
|
|
4
5
|
* The OpenSearch Contributors require contributions made to
|
|
5
6
|
* this file be licensed under the Apache-2.0 license or a
|
|
6
7
|
* compatible open source license.
|
|
7
8
|
*
|
|
8
|
-
* Modifications Copyright OpenSearch Contributors. See
|
|
9
|
-
* GitHub history for details.
|
|
10
9
|
*/
|
|
11
10
|
|
|
12
11
|
/*
|
|
@@ -28,40 +27,71 @@
|
|
|
28
27
|
* under the License.
|
|
29
28
|
*/
|
|
30
29
|
|
|
31
|
-
'use strict'
|
|
30
|
+
'use strict';
|
|
32
31
|
|
|
33
32
|
/* eslint camelcase: 0 */
|
|
34
33
|
/* eslint no-unused-vars: 0 */
|
|
35
34
|
|
|
36
|
-
const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
|
|
37
|
-
const acceptedQuerystring = [
|
|
38
|
-
|
|
35
|
+
const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
|
|
36
|
+
const acceptedQuerystring = [
|
|
37
|
+
'term_statistics',
|
|
38
|
+
'field_statistics',
|
|
39
|
+
'fields',
|
|
40
|
+
'offsets',
|
|
41
|
+
'positions',
|
|
42
|
+
'payloads',
|
|
43
|
+
'preference',
|
|
44
|
+
'routing',
|
|
45
|
+
'realtime',
|
|
46
|
+
'version',
|
|
47
|
+
'version_type',
|
|
48
|
+
'pretty',
|
|
49
|
+
'human',
|
|
50
|
+
'error_trace',
|
|
51
|
+
'source',
|
|
52
|
+
'filter_path',
|
|
53
|
+
];
|
|
54
|
+
const snakeCase = {
|
|
55
|
+
termStatistics: 'term_statistics',
|
|
56
|
+
fieldStatistics: 'field_statistics',
|
|
57
|
+
versionType: 'version_type',
|
|
58
|
+
errorTrace: 'error_trace',
|
|
59
|
+
filterPath: 'filter_path',
|
|
60
|
+
};
|
|
39
61
|
|
|
40
|
-
function termvectorsApi
|
|
41
|
-
|
|
62
|
+
function termvectorsApi(params, options, callback) {
|
|
63
|
+
[params, options, callback] = normalizeArguments(params, options, callback);
|
|
42
64
|
|
|
43
65
|
// check required parameters
|
|
44
66
|
if (params.index == null) {
|
|
45
|
-
const err = new this[kConfigurationError]('Missing required parameter: index')
|
|
46
|
-
return handleError(err, callback)
|
|
67
|
+
const err = new this[kConfigurationError]('Missing required parameter: index');
|
|
68
|
+
return handleError(err, callback);
|
|
47
69
|
}
|
|
48
70
|
|
|
49
|
-
let { method, body, index, id, type, ...querystring } = params
|
|
50
|
-
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
|
|
71
|
+
let { method, body, index, id, type, ...querystring } = params;
|
|
72
|
+
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
|
|
51
73
|
|
|
52
|
-
let path = ''
|
|
53
|
-
if (
|
|
54
|
-
if (method == null) method = body == null ? 'GET' : 'POST'
|
|
55
|
-
path =
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
74
|
+
let path = '';
|
|
75
|
+
if (index != null && type != null && id != null) {
|
|
76
|
+
if (method == null) method = body == null ? 'GET' : 'POST';
|
|
77
|
+
path =
|
|
78
|
+
'/' +
|
|
79
|
+
encodeURIComponent(index) +
|
|
80
|
+
'/' +
|
|
81
|
+
encodeURIComponent(type) +
|
|
82
|
+
'/' +
|
|
83
|
+
encodeURIComponent(id) +
|
|
84
|
+
'/' +
|
|
85
|
+
'_termvectors';
|
|
86
|
+
} else if (index != null && id != null) {
|
|
87
|
+
if (method == null) method = body == null ? 'GET' : 'POST';
|
|
88
|
+
path = '/' + encodeURIComponent(index) + '/' + '_termvectors' + '/' + encodeURIComponent(id);
|
|
89
|
+
} else if (index != null && type != null) {
|
|
90
|
+
if (method == null) method = body == null ? 'GET' : 'POST';
|
|
91
|
+
path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_termvectors';
|
|
62
92
|
} else {
|
|
63
|
-
if (method == null) method = body == null ? 'GET' : 'POST'
|
|
64
|
-
path = '/' + encodeURIComponent(index) + '/' + '_termvectors'
|
|
93
|
+
if (method == null) method = body == null ? 'GET' : 'POST';
|
|
94
|
+
path = '/' + encodeURIComponent(index) + '/' + '_termvectors';
|
|
65
95
|
}
|
|
66
96
|
|
|
67
97
|
// build request object
|
|
@@ -69,10 +99,10 @@ function termvectorsApi (params, options, callback) {
|
|
|
69
99
|
method,
|
|
70
100
|
path,
|
|
71
101
|
body: body || '',
|
|
72
|
-
querystring
|
|
73
|
-
}
|
|
102
|
+
querystring,
|
|
103
|
+
};
|
|
74
104
|
|
|
75
|
-
return this.transport.request(request, options, callback)
|
|
105
|
+
return this.transport.request(request, options, callback);
|
|
76
106
|
}
|
|
77
107
|
|
|
78
|
-
module.exports = termvectorsApi
|
|
108
|
+
module.exports = termvectorsApi;
|
package/api/api/update.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
2
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
3
4
|
*
|
|
4
5
|
* The OpenSearch Contributors require contributions made to
|
|
5
6
|
* this file be licensed under the Apache-2.0 license or a
|
|
6
7
|
* compatible open source license.
|
|
7
8
|
*
|
|
8
|
-
* Modifications Copyright OpenSearch Contributors. See
|
|
9
|
-
* GitHub history for details.
|
|
10
9
|
*/
|
|
11
10
|
|
|
12
11
|
/*
|
|
@@ -28,42 +27,82 @@
|
|
|
28
27
|
* under the License.
|
|
29
28
|
*/
|
|
30
29
|
|
|
31
|
-
'use strict'
|
|
30
|
+
'use strict';
|
|
32
31
|
|
|
33
32
|
/* eslint camelcase: 0 */
|
|
34
33
|
/* eslint no-unused-vars: 0 */
|
|
35
34
|
|
|
36
|
-
const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
|
|
37
|
-
const acceptedQuerystring = [
|
|
38
|
-
|
|
35
|
+
const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
|
|
36
|
+
const acceptedQuerystring = [
|
|
37
|
+
'wait_for_active_shards',
|
|
38
|
+
'_source',
|
|
39
|
+
'_source_excludes',
|
|
40
|
+
'_source_exclude',
|
|
41
|
+
'_source_includes',
|
|
42
|
+
'_source_include',
|
|
43
|
+
'lang',
|
|
44
|
+
'refresh',
|
|
45
|
+
'retry_on_conflict',
|
|
46
|
+
'routing',
|
|
47
|
+
'timeout',
|
|
48
|
+
'if_seq_no',
|
|
49
|
+
'if_primary_term',
|
|
50
|
+
'require_alias',
|
|
51
|
+
'pretty',
|
|
52
|
+
'human',
|
|
53
|
+
'error_trace',
|
|
54
|
+
'source',
|
|
55
|
+
'filter_path',
|
|
56
|
+
];
|
|
57
|
+
const snakeCase = {
|
|
58
|
+
waitForActiveShards: 'wait_for_active_shards',
|
|
59
|
+
_sourceExcludes: '_source_excludes',
|
|
60
|
+
_sourceExclude: '_source_exclude',
|
|
61
|
+
_sourceIncludes: '_source_includes',
|
|
62
|
+
_sourceInclude: '_source_include',
|
|
63
|
+
retryOnConflict: 'retry_on_conflict',
|
|
64
|
+
ifSeqNo: 'if_seq_no',
|
|
65
|
+
ifPrimaryTerm: 'if_primary_term',
|
|
66
|
+
requireAlias: 'require_alias',
|
|
67
|
+
errorTrace: 'error_trace',
|
|
68
|
+
filterPath: 'filter_path',
|
|
69
|
+
};
|
|
39
70
|
|
|
40
|
-
function updateApi
|
|
41
|
-
|
|
71
|
+
function updateApi(params, options, callback) {
|
|
72
|
+
[params, options, callback] = normalizeArguments(params, options, callback);
|
|
42
73
|
|
|
43
74
|
// check required parameters
|
|
44
75
|
if (params.id == null) {
|
|
45
|
-
const err = new this[kConfigurationError]('Missing required parameter: id')
|
|
46
|
-
return handleError(err, callback)
|
|
76
|
+
const err = new this[kConfigurationError]('Missing required parameter: id');
|
|
77
|
+
return handleError(err, callback);
|
|
47
78
|
}
|
|
48
79
|
if (params.index == null) {
|
|
49
|
-
const err = new this[kConfigurationError]('Missing required parameter: index')
|
|
50
|
-
return handleError(err, callback)
|
|
80
|
+
const err = new this[kConfigurationError]('Missing required parameter: index');
|
|
81
|
+
return handleError(err, callback);
|
|
51
82
|
}
|
|
52
83
|
if (params.body == null) {
|
|
53
|
-
const err = new this[kConfigurationError]('Missing required parameter: body')
|
|
54
|
-
return handleError(err, callback)
|
|
84
|
+
const err = new this[kConfigurationError]('Missing required parameter: body');
|
|
85
|
+
return handleError(err, callback);
|
|
55
86
|
}
|
|
56
87
|
|
|
57
|
-
let { method, body, id, index, type, ...querystring } = params
|
|
58
|
-
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
|
|
88
|
+
let { method, body, id, index, type, ...querystring } = params;
|
|
89
|
+
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
|
|
59
90
|
|
|
60
|
-
let path = ''
|
|
61
|
-
if (
|
|
62
|
-
if (method == null) method = 'POST'
|
|
63
|
-
path =
|
|
91
|
+
let path = '';
|
|
92
|
+
if (index != null && type != null && id != null) {
|
|
93
|
+
if (method == null) method = 'POST';
|
|
94
|
+
path =
|
|
95
|
+
'/' +
|
|
96
|
+
encodeURIComponent(index) +
|
|
97
|
+
'/' +
|
|
98
|
+
encodeURIComponent(type) +
|
|
99
|
+
'/' +
|
|
100
|
+
encodeURIComponent(id) +
|
|
101
|
+
'/' +
|
|
102
|
+
'_update';
|
|
64
103
|
} else {
|
|
65
|
-
if (method == null) method = 'POST'
|
|
66
|
-
path = '/' + encodeURIComponent(index) + '/' + '_update' + '/' + encodeURIComponent(id)
|
|
104
|
+
if (method == null) method = 'POST';
|
|
105
|
+
path = '/' + encodeURIComponent(index) + '/' + '_update' + '/' + encodeURIComponent(id);
|
|
67
106
|
}
|
|
68
107
|
|
|
69
108
|
// build request object
|
|
@@ -71,10 +110,10 @@ function updateApi (params, options, callback) {
|
|
|
71
110
|
method,
|
|
72
111
|
path,
|
|
73
112
|
body: body || '',
|
|
74
|
-
querystring
|
|
75
|
-
}
|
|
113
|
+
querystring,
|
|
114
|
+
};
|
|
76
115
|
|
|
77
|
-
return this.transport.request(request, options, callback)
|
|
116
|
+
return this.transport.request(request, options, callback);
|
|
78
117
|
}
|
|
79
118
|
|
|
80
|
-
module.exports = updateApi
|
|
119
|
+
module.exports = updateApi;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
+
* Copyright OpenSearch Contributors
|
|
2
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
3
4
|
*
|
|
4
5
|
* The OpenSearch Contributors require contributions made to
|
|
5
6
|
* this file be licensed under the Apache-2.0 license or a
|
|
6
7
|
* compatible open source license.
|
|
7
8
|
*
|
|
8
|
-
* Modifications Copyright OpenSearch Contributors. See
|
|
9
|
-
* GitHub history for details.
|
|
10
9
|
*/
|
|
11
10
|
|
|
12
11
|
/*
|
|
@@ -28,40 +27,106 @@
|
|
|
28
27
|
* under the License.
|
|
29
28
|
*/
|
|
30
29
|
|
|
31
|
-
'use strict'
|
|
30
|
+
'use strict';
|
|
32
31
|
|
|
33
32
|
/* eslint camelcase: 0 */
|
|
34
33
|
/* eslint no-unused-vars: 0 */
|
|
35
34
|
|
|
36
|
-
const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
|
|
37
|
-
const acceptedQuerystring = [
|
|
38
|
-
|
|
35
|
+
const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
|
|
36
|
+
const acceptedQuerystring = [
|
|
37
|
+
'analyzer',
|
|
38
|
+
'analyze_wildcard',
|
|
39
|
+
'default_operator',
|
|
40
|
+
'df',
|
|
41
|
+
'from',
|
|
42
|
+
'ignore_unavailable',
|
|
43
|
+
'allow_no_indices',
|
|
44
|
+
'conflicts',
|
|
45
|
+
'expand_wildcards',
|
|
46
|
+
'lenient',
|
|
47
|
+
'pipeline',
|
|
48
|
+
'preference',
|
|
49
|
+
'q',
|
|
50
|
+
'routing',
|
|
51
|
+
'scroll',
|
|
52
|
+
'search_type',
|
|
53
|
+
'search_timeout',
|
|
54
|
+
'size',
|
|
55
|
+
'max_docs',
|
|
56
|
+
'sort',
|
|
57
|
+
'_source',
|
|
58
|
+
'_source_excludes',
|
|
59
|
+
'_source_exclude',
|
|
60
|
+
'_source_includes',
|
|
61
|
+
'_source_include',
|
|
62
|
+
'terminate_after',
|
|
63
|
+
'stats',
|
|
64
|
+
'version',
|
|
65
|
+
'version_type',
|
|
66
|
+
'request_cache',
|
|
67
|
+
'refresh',
|
|
68
|
+
'timeout',
|
|
69
|
+
'wait_for_active_shards',
|
|
70
|
+
'scroll_size',
|
|
71
|
+
'wait_for_completion',
|
|
72
|
+
'requests_per_second',
|
|
73
|
+
'slices',
|
|
74
|
+
'pretty',
|
|
75
|
+
'human',
|
|
76
|
+
'error_trace',
|
|
77
|
+
'source',
|
|
78
|
+
'filter_path',
|
|
79
|
+
];
|
|
80
|
+
const snakeCase = {
|
|
81
|
+
analyzeWildcard: 'analyze_wildcard',
|
|
82
|
+
defaultOperator: 'default_operator',
|
|
83
|
+
ignoreUnavailable: 'ignore_unavailable',
|
|
84
|
+
allowNoIndices: 'allow_no_indices',
|
|
85
|
+
expandWildcards: 'expand_wildcards',
|
|
86
|
+
searchType: 'search_type',
|
|
87
|
+
searchTimeout: 'search_timeout',
|
|
88
|
+
maxDocs: 'max_docs',
|
|
89
|
+
_sourceExcludes: '_source_excludes',
|
|
90
|
+
_sourceExclude: '_source_exclude',
|
|
91
|
+
_sourceIncludes: '_source_includes',
|
|
92
|
+
_sourceInclude: '_source_include',
|
|
93
|
+
terminateAfter: 'terminate_after',
|
|
94
|
+
versionType: 'version_type',
|
|
95
|
+
requestCache: 'request_cache',
|
|
96
|
+
waitForActiveShards: 'wait_for_active_shards',
|
|
97
|
+
scrollSize: 'scroll_size',
|
|
98
|
+
waitForCompletion: 'wait_for_completion',
|
|
99
|
+
requestsPerSecond: 'requests_per_second',
|
|
100
|
+
errorTrace: 'error_trace',
|
|
101
|
+
filterPath: 'filter_path',
|
|
102
|
+
};
|
|
39
103
|
|
|
40
|
-
function updateByQueryApi
|
|
41
|
-
|
|
104
|
+
function updateByQueryApi(params, options, callback) {
|
|
105
|
+
[params, options, callback] = normalizeArguments(params, options, callback);
|
|
42
106
|
|
|
43
107
|
// check required parameters
|
|
44
108
|
if (params.index == null) {
|
|
45
|
-
const err = new this[kConfigurationError]('Missing required parameter: index')
|
|
46
|
-
return handleError(err, callback)
|
|
109
|
+
const err = new this[kConfigurationError]('Missing required parameter: index');
|
|
110
|
+
return handleError(err, callback);
|
|
47
111
|
}
|
|
48
112
|
|
|
49
113
|
// check required url components
|
|
50
|
-
if (params.type != null &&
|
|
51
|
-
const err = new this[kConfigurationError]('Missing required parameter of the url: index')
|
|
52
|
-
return handleError(err, callback)
|
|
114
|
+
if (params.type != null && params.index == null) {
|
|
115
|
+
const err = new this[kConfigurationError]('Missing required parameter of the url: index');
|
|
116
|
+
return handleError(err, callback);
|
|
53
117
|
}
|
|
54
118
|
|
|
55
|
-
let { method, body, index, type, ...querystring } = params
|
|
56
|
-
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
|
|
119
|
+
let { method, body, index, type, ...querystring } = params;
|
|
120
|
+
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
|
|
57
121
|
|
|
58
|
-
let path = ''
|
|
59
|
-
if (
|
|
60
|
-
if (method == null) method = 'POST'
|
|
61
|
-
path =
|
|
122
|
+
let path = '';
|
|
123
|
+
if (index != null && type != null) {
|
|
124
|
+
if (method == null) method = 'POST';
|
|
125
|
+
path =
|
|
126
|
+
'/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_update_by_query';
|
|
62
127
|
} else {
|
|
63
|
-
if (method == null) method = 'POST'
|
|
64
|
-
path = '/' + encodeURIComponent(index) + '/' + '_update_by_query'
|
|
128
|
+
if (method == null) method = 'POST';
|
|
129
|
+
path = '/' + encodeURIComponent(index) + '/' + '_update_by_query';
|
|
65
130
|
}
|
|
66
131
|
|
|
67
132
|
// build request object
|
|
@@ -69,10 +134,10 @@ function updateByQueryApi (params, options, callback) {
|
|
|
69
134
|
method,
|
|
70
135
|
path,
|
|
71
136
|
body: body || '',
|
|
72
|
-
querystring
|
|
73
|
-
}
|
|
137
|
+
querystring,
|
|
138
|
+
};
|
|
74
139
|
|
|
75
|
-
return this.transport.request(request, options, callback)
|
|
140
|
+
return this.transport.request(request, options, callback);
|
|
76
141
|
}
|
|
77
142
|
|
|
78
|
-
module.exports = updateByQueryApi
|
|
143
|
+
module.exports = updateByQueryApi;
|