@opensearch-project/opensearch 1.0.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.
Files changed (84) hide show
  1. package/.dockerignore +5 -0
  2. package/ADMINS.md +34 -0
  3. package/DEVELOPER_GUIDE.md +60 -0
  4. package/LICENSE.txt +201 -0
  5. package/MAINTAINERS.md +73 -0
  6. package/Makefile +27 -0
  7. package/NOTICE.txt +8 -0
  8. package/README.md +183 -0
  9. package/RELEASING.md +34 -0
  10. package/SECURITY.md +3 -0
  11. package/api/api/bulk.js +81 -0
  12. package/api/api/cat.js +525 -0
  13. package/api/api/clear_scroll.js +66 -0
  14. package/api/api/cluster.js +431 -0
  15. package/api/api/count.js +75 -0
  16. package/api/api/create.js +80 -0
  17. package/api/api/dangling_indices.js +126 -0
  18. package/api/api/delete.js +76 -0
  19. package/api/api/delete_by_query.js +82 -0
  20. package/api/api/delete_by_query_rethrottle.js +71 -0
  21. package/api/api/delete_script.js +67 -0
  22. package/api/api/exists.js +76 -0
  23. package/api/api/exists_source.js +85 -0
  24. package/api/api/explain.js +76 -0
  25. package/api/api/features.js +92 -0
  26. package/api/api/field_caps.js +66 -0
  27. package/api/api/get.js +76 -0
  28. package/api/api/get_script.js +67 -0
  29. package/api/api/get_script_context.js +61 -0
  30. package/api/api/get_script_languages.js +61 -0
  31. package/api/api/get_source.js +76 -0
  32. package/api/api/index.js +82 -0
  33. package/api/api/indices.js +1516 -0
  34. package/api/api/info.js +61 -0
  35. package/api/api/ingest.js +211 -0
  36. package/api/api/mget.js +81 -0
  37. package/api/api/msearch.js +81 -0
  38. package/api/api/msearch_template.js +81 -0
  39. package/api/api/mtermvectors.js +75 -0
  40. package/api/api/nodes.js +279 -0
  41. package/api/api/ping.js +61 -0
  42. package/api/api/put_script.js +82 -0
  43. package/api/api/rank_eval.js +72 -0
  44. package/api/api/reindex.js +67 -0
  45. package/api/api/reindex_rethrottle.js +71 -0
  46. package/api/api/render_search_template.js +66 -0
  47. package/api/api/scripts_painless_execute.js +61 -0
  48. package/api/api/scroll.js +66 -0
  49. package/api/api/search.js +75 -0
  50. package/api/api/search_shards.js +66 -0
  51. package/api/api/search_template.js +81 -0
  52. package/api/api/shutdown.js +135 -0
  53. package/api/api/snapshot.js +450 -0
  54. package/api/api/tasks.js +119 -0
  55. package/api/api/terms_enum.js +67 -0
  56. package/api/api/termvectors.js +78 -0
  57. package/api/api/update.js +80 -0
  58. package/api/api/update_by_query.js +78 -0
  59. package/api/api/update_by_query_rethrottle.js +71 -0
  60. package/api/index.js +254 -0
  61. package/api/new.d.ts +716 -0
  62. package/api/requestParams.d.ts +1583 -0
  63. package/api/types.d.ts +9481 -0
  64. package/api/utils.js +69 -0
  65. package/codecov.yml +14 -0
  66. package/index.d.ts +1210 -0
  67. package/index.js +338 -0
  68. package/index.mjs +40 -0
  69. package/lib/Connection.d.ts +107 -0
  70. package/lib/Connection.js +345 -0
  71. package/lib/Helpers.d.ts +135 -0
  72. package/lib/Helpers.js +779 -0
  73. package/lib/Serializer.d.ts +41 -0
  74. package/lib/Serializer.js +105 -0
  75. package/lib/Transport.d.ts +173 -0
  76. package/lib/Transport.js +646 -0
  77. package/lib/errors.d.ts +101 -0
  78. package/lib/errors.js +168 -0
  79. package/lib/pool/BaseConnectionPool.js +269 -0
  80. package/lib/pool/CloudConnectionPool.js +75 -0
  81. package/lib/pool/ConnectionPool.js +257 -0
  82. package/lib/pool/index.d.ts +215 -0
  83. package/lib/pool/index.js +41 -0
  84. package/package.json +102 -0
@@ -0,0 +1,61 @@
1
+ /*
2
+ * SPDX-License-Identifier: Apache-2.0
3
+ *
4
+ * The OpenSearch Contributors require contributions made to
5
+ * this file be licensed under the Apache-2.0 license or a
6
+ * compatible open source license.
7
+ *
8
+ * Modifications Copyright OpenSearch Contributors. See
9
+ * GitHub history for details.
10
+ */
11
+
12
+ /*
13
+ * Licensed to Elasticsearch B.V. under one or more contributor
14
+ * license agreements. See the NOTICE file distributed with
15
+ * this work for additional information regarding copyright
16
+ * ownership. Elasticsearch B.V. licenses this file to you under
17
+ * the Apache License, Version 2.0 (the "License"); you may
18
+ * not use this file except in compliance with the License.
19
+ * You may obtain a copy of the License at
20
+ *
21
+ * http://www.apache.org/licenses/LICENSE-2.0
22
+ *
23
+ * Unless required by applicable law or agreed to in writing,
24
+ * software distributed under the License is distributed on an
25
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
26
+ * KIND, either express or implied. See the License for the
27
+ * specific language governing permissions and limitations
28
+ * under the License.
29
+ */
30
+
31
+ 'use strict'
32
+
33
+ /* eslint camelcase: 0 */
34
+ /* eslint no-unused-vars: 0 */
35
+
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' }
39
+
40
+ function infoApi (params, options, callback) {
41
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
42
+
43
+ let { method, body, ...querystring } = params
44
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
45
+
46
+ let path = ''
47
+ if (method == null) method = 'GET'
48
+ path = '/'
49
+
50
+ // build request object
51
+ const request = {
52
+ method,
53
+ path,
54
+ body: null,
55
+ querystring
56
+ }
57
+
58
+ return this.transport.request(request, options, callback)
59
+ }
60
+
61
+ module.exports = infoApi
@@ -0,0 +1,211 @@
1
+ /*
2
+ * SPDX-License-Identifier: Apache-2.0
3
+ *
4
+ * The OpenSearch Contributors require contributions made to
5
+ * this file be licensed under the Apache-2.0 license or a
6
+ * compatible open source license.
7
+ *
8
+ * Modifications Copyright OpenSearch Contributors. See
9
+ * GitHub history for details.
10
+ */
11
+
12
+ /*
13
+ * Licensed to Elasticsearch B.V. under one or more contributor
14
+ * license agreements. See the NOTICE file distributed with
15
+ * this work for additional information regarding copyright
16
+ * ownership. Elasticsearch B.V. licenses this file to you under
17
+ * the Apache License, Version 2.0 (the "License"); you may
18
+ * not use this file except in compliance with the License.
19
+ * You may obtain a copy of the License at
20
+ *
21
+ * http://www.apache.org/licenses/LICENSE-2.0
22
+ *
23
+ * Unless required by applicable law or agreed to in writing,
24
+ * software distributed under the License is distributed on an
25
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
26
+ * KIND, either express or implied. See the License for the
27
+ * specific language governing permissions and limitations
28
+ * under the License.
29
+ */
30
+
31
+ 'use strict'
32
+
33
+ /* eslint camelcase: 0 */
34
+ /* eslint no-unused-vars: 0 */
35
+
36
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
37
+ const acceptedQuerystring = ['master_timeout', 'timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'summary', 'verbose']
38
+ const snakeCase = { masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path' }
39
+
40
+ function IngestApi (transport, ConfigurationError) {
41
+ this.transport = transport
42
+ this[kConfigurationError] = ConfigurationError
43
+ }
44
+
45
+ IngestApi.prototype.deletePipeline = function ingestDeletePipelineApi (params, options, callback) {
46
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
47
+
48
+ // check required parameters
49
+ if (params.id == null) {
50
+ const err = new this[kConfigurationError]('Missing required parameter: id')
51
+ return handleError(err, callback)
52
+ }
53
+
54
+ let { method, body, id, ...querystring } = params
55
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
56
+
57
+ let path = ''
58
+ if (method == null) method = 'DELETE'
59
+ path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id)
60
+
61
+ // build request object
62
+ const request = {
63
+ method,
64
+ path,
65
+ body: body || '',
66
+ querystring
67
+ }
68
+
69
+ return this.transport.request(request, options, callback)
70
+ }
71
+
72
+ IngestApi.prototype.geoIpStats = function ingestGeoIpStatsApi (params, options, callback) {
73
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
74
+
75
+ let { method, body, ...querystring } = params
76
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
77
+
78
+ let path = ''
79
+ if (method == null) method = 'GET'
80
+ path = '/' + '_ingest' + '/' + 'geoip' + '/' + 'stats'
81
+
82
+ // build request object
83
+ const request = {
84
+ method,
85
+ path,
86
+ body: null,
87
+ querystring
88
+ }
89
+
90
+ return this.transport.request(request, options, callback)
91
+ }
92
+
93
+ IngestApi.prototype.getPipeline = function ingestGetPipelineApi (params, options, callback) {
94
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
95
+
96
+ let { method, body, id, ...querystring } = params
97
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
98
+
99
+ let path = ''
100
+ if ((id) != null) {
101
+ if (method == null) method = 'GET'
102
+ path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id)
103
+ } else {
104
+ if (method == null) method = 'GET'
105
+ path = '/' + '_ingest' + '/' + 'pipeline'
106
+ }
107
+
108
+ // build request object
109
+ const request = {
110
+ method,
111
+ path,
112
+ body: null,
113
+ querystring
114
+ }
115
+
116
+ return this.transport.request(request, options, callback)
117
+ }
118
+
119
+ IngestApi.prototype.processorGrok = function ingestProcessorGrokApi (params, options, callback) {
120
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
121
+
122
+ let { method, body, ...querystring } = params
123
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
124
+
125
+ let path = ''
126
+ if (method == null) method = 'GET'
127
+ path = '/' + '_ingest' + '/' + 'processor' + '/' + 'grok'
128
+
129
+ // build request object
130
+ const request = {
131
+ method,
132
+ path,
133
+ body: null,
134
+ querystring
135
+ }
136
+
137
+ return this.transport.request(request, options, callback)
138
+ }
139
+
140
+ IngestApi.prototype.putPipeline = function ingestPutPipelineApi (params, options, callback) {
141
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
142
+
143
+ // check required parameters
144
+ if (params.id == null) {
145
+ const err = new this[kConfigurationError]('Missing required parameter: id')
146
+ return handleError(err, callback)
147
+ }
148
+ if (params.body == null) {
149
+ const err = new this[kConfigurationError]('Missing required parameter: body')
150
+ return handleError(err, callback)
151
+ }
152
+
153
+ let { method, body, id, ...querystring } = params
154
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
155
+
156
+ let path = ''
157
+ if (method == null) method = 'PUT'
158
+ path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id)
159
+
160
+ // build request object
161
+ const request = {
162
+ method,
163
+ path,
164
+ body: body || '',
165
+ querystring
166
+ }
167
+
168
+ return this.transport.request(request, options, callback)
169
+ }
170
+
171
+ IngestApi.prototype.simulate = function ingestSimulateApi (params, options, callback) {
172
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
173
+
174
+ // check required parameters
175
+ if (params.body == null) {
176
+ const err = new this[kConfigurationError]('Missing required parameter: body')
177
+ return handleError(err, callback)
178
+ }
179
+
180
+ let { method, body, id, ...querystring } = params
181
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
182
+
183
+ let path = ''
184
+ if ((id) != null) {
185
+ if (method == null) method = body == null ? 'GET' : 'POST'
186
+ path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id) + '/' + '_simulate'
187
+ } else {
188
+ if (method == null) method = body == null ? 'GET' : 'POST'
189
+ path = '/' + '_ingest' + '/' + 'pipeline' + '/' + '_simulate'
190
+ }
191
+
192
+ // build request object
193
+ const request = {
194
+ method,
195
+ path,
196
+ body: body || '',
197
+ querystring
198
+ }
199
+
200
+ return this.transport.request(request, options, callback)
201
+ }
202
+
203
+ Object.defineProperties(IngestApi.prototype, {
204
+ delete_pipeline: { get () { return this.deletePipeline } },
205
+ geo_ip_stats: { get () { return this.geoIpStats } },
206
+ get_pipeline: { get () { return this.getPipeline } },
207
+ processor_grok: { get () { return this.processorGrok } },
208
+ put_pipeline: { get () { return this.putPipeline } }
209
+ })
210
+
211
+ module.exports = IngestApi
@@ -0,0 +1,81 @@
1
+ /*
2
+ * SPDX-License-Identifier: Apache-2.0
3
+ *
4
+ * The OpenSearch Contributors require contributions made to
5
+ * this file be licensed under the Apache-2.0 license or a
6
+ * compatible open source license.
7
+ *
8
+ * Modifications Copyright OpenSearch Contributors. See
9
+ * GitHub history for details.
10
+ */
11
+
12
+ /*
13
+ * Licensed to Elasticsearch B.V. under one or more contributor
14
+ * license agreements. See the NOTICE file distributed with
15
+ * this work for additional information regarding copyright
16
+ * ownership. Elasticsearch B.V. licenses this file to you under
17
+ * the Apache License, Version 2.0 (the "License"); you may
18
+ * not use this file except in compliance with the License.
19
+ * You may obtain a copy of the License at
20
+ *
21
+ * http://www.apache.org/licenses/LICENSE-2.0
22
+ *
23
+ * Unless required by applicable law or agreed to in writing,
24
+ * software distributed under the License is distributed on an
25
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
26
+ * KIND, either express or implied. See the License for the
27
+ * specific language governing permissions and limitations
28
+ * under the License.
29
+ */
30
+
31
+ 'use strict'
32
+
33
+ /* eslint camelcase: 0 */
34
+ /* eslint no-unused-vars: 0 */
35
+
36
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
37
+ const acceptedQuerystring = ['stored_fields', 'preference', 'realtime', 'refresh', 'routing', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
38
+ const snakeCase = { storedFields: 'stored_fields', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', errorTrace: 'error_trace', filterPath: 'filter_path' }
39
+
40
+ function mgetApi (params, options, callback) {
41
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
42
+
43
+ // check required parameters
44
+ if (params.body == null) {
45
+ const err = new this[kConfigurationError]('Missing required parameter: body')
46
+ return handleError(err, callback)
47
+ }
48
+
49
+ // check required url components
50
+ if (params.type != null && (params.index == null)) {
51
+ const err = new this[kConfigurationError]('Missing required parameter of the url: index')
52
+ return handleError(err, callback)
53
+ }
54
+
55
+ let { method, body, index, type, ...querystring } = params
56
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
57
+
58
+ let path = ''
59
+ if ((index) != null && (type) != null) {
60
+ if (method == null) method = body == null ? 'GET' : 'POST'
61
+ path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_mget'
62
+ } else if ((index) != null) {
63
+ if (method == null) method = body == null ? 'GET' : 'POST'
64
+ path = '/' + encodeURIComponent(index) + '/' + '_mget'
65
+ } else {
66
+ if (method == null) method = body == null ? 'GET' : 'POST'
67
+ path = '/' + '_mget'
68
+ }
69
+
70
+ // build request object
71
+ const request = {
72
+ method,
73
+ path,
74
+ body: body || '',
75
+ querystring
76
+ }
77
+
78
+ return this.transport.request(request, options, callback)
79
+ }
80
+
81
+ module.exports = mgetApi
@@ -0,0 +1,81 @@
1
+ /*
2
+ * SPDX-License-Identifier: Apache-2.0
3
+ *
4
+ * The OpenSearch Contributors require contributions made to
5
+ * this file be licensed under the Apache-2.0 license or a
6
+ * compatible open source license.
7
+ *
8
+ * Modifications Copyright OpenSearch Contributors. See
9
+ * GitHub history for details.
10
+ */
11
+
12
+ /*
13
+ * Licensed to Elasticsearch B.V. under one or more contributor
14
+ * license agreements. See the NOTICE file distributed with
15
+ * this work for additional information regarding copyright
16
+ * ownership. Elasticsearch B.V. licenses this file to you under
17
+ * the Apache License, Version 2.0 (the "License"); you may
18
+ * not use this file except in compliance with the License.
19
+ * You may obtain a copy of the License at
20
+ *
21
+ * http://www.apache.org/licenses/LICENSE-2.0
22
+ *
23
+ * Unless required by applicable law or agreed to in writing,
24
+ * software distributed under the License is distributed on an
25
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
26
+ * KIND, either express or implied. See the License for the
27
+ * specific language governing permissions and limitations
28
+ * under the License.
29
+ */
30
+
31
+ 'use strict'
32
+
33
+ /* eslint camelcase: 0 */
34
+ /* eslint no-unused-vars: 0 */
35
+
36
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
37
+ const acceptedQuerystring = ['search_type', 'max_concurrent_searches', 'typed_keys', 'pre_filter_shard_size', 'max_concurrent_shard_requests', 'rest_total_hits_as_int', 'ccs_minimize_roundtrips', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
38
+ const snakeCase = { searchType: 'search_type', maxConcurrentSearches: 'max_concurrent_searches', typedKeys: 'typed_keys', preFilterShardSize: 'pre_filter_shard_size', maxConcurrentShardRequests: 'max_concurrent_shard_requests', restTotalHitsAsInt: 'rest_total_hits_as_int', ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips', errorTrace: 'error_trace', filterPath: 'filter_path' }
39
+
40
+ function msearchApi (params, options, callback) {
41
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
42
+
43
+ // check required parameters
44
+ if (params.body == null) {
45
+ const err = new this[kConfigurationError]('Missing required parameter: body')
46
+ return handleError(err, callback)
47
+ }
48
+
49
+ // check required url components
50
+ if (params.type != null && (params.index == null)) {
51
+ const err = new this[kConfigurationError]('Missing required parameter of the url: index')
52
+ return handleError(err, callback)
53
+ }
54
+
55
+ let { method, body, index, type, ...querystring } = params
56
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
57
+
58
+ let path = ''
59
+ if ((index) != null && (type) != null) {
60
+ if (method == null) method = body == null ? 'GET' : 'POST'
61
+ path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_msearch'
62
+ } else if ((index) != null) {
63
+ if (method == null) method = body == null ? 'GET' : 'POST'
64
+ path = '/' + encodeURIComponent(index) + '/' + '_msearch'
65
+ } else {
66
+ if (method == null) method = body == null ? 'GET' : 'POST'
67
+ path = '/' + '_msearch'
68
+ }
69
+
70
+ // build request object
71
+ const request = {
72
+ method,
73
+ path,
74
+ bulkBody: body,
75
+ querystring
76
+ }
77
+
78
+ return this.transport.request(request, options, callback)
79
+ }
80
+
81
+ module.exports = msearchApi
@@ -0,0 +1,81 @@
1
+ /*
2
+ * SPDX-License-Identifier: Apache-2.0
3
+ *
4
+ * The OpenSearch Contributors require contributions made to
5
+ * this file be licensed under the Apache-2.0 license or a
6
+ * compatible open source license.
7
+ *
8
+ * Modifications Copyright OpenSearch Contributors. See
9
+ * GitHub history for details.
10
+ */
11
+
12
+ /*
13
+ * Licensed to Elasticsearch B.V. under one or more contributor
14
+ * license agreements. See the NOTICE file distributed with
15
+ * this work for additional information regarding copyright
16
+ * ownership. Elasticsearch B.V. licenses this file to you under
17
+ * the Apache License, Version 2.0 (the "License"); you may
18
+ * not use this file except in compliance with the License.
19
+ * You may obtain a copy of the License at
20
+ *
21
+ * http://www.apache.org/licenses/LICENSE-2.0
22
+ *
23
+ * Unless required by applicable law or agreed to in writing,
24
+ * software distributed under the License is distributed on an
25
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
26
+ * KIND, either express or implied. See the License for the
27
+ * specific language governing permissions and limitations
28
+ * under the License.
29
+ */
30
+
31
+ 'use strict'
32
+
33
+ /* eslint camelcase: 0 */
34
+ /* eslint no-unused-vars: 0 */
35
+
36
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
37
+ const acceptedQuerystring = ['search_type', 'typed_keys', 'max_concurrent_searches', 'rest_total_hits_as_int', 'ccs_minimize_roundtrips', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
38
+ const snakeCase = { searchType: 'search_type', typedKeys: 'typed_keys', maxConcurrentSearches: 'max_concurrent_searches', restTotalHitsAsInt: 'rest_total_hits_as_int', ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips', errorTrace: 'error_trace', filterPath: 'filter_path' }
39
+
40
+ function msearchTemplateApi (params, options, callback) {
41
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
42
+
43
+ // check required parameters
44
+ if (params.body == null) {
45
+ const err = new this[kConfigurationError]('Missing required parameter: body')
46
+ return handleError(err, callback)
47
+ }
48
+
49
+ // check required url components
50
+ if (params.type != null && (params.index == null)) {
51
+ const err = new this[kConfigurationError]('Missing required parameter of the url: index')
52
+ return handleError(err, callback)
53
+ }
54
+
55
+ let { method, body, index, type, ...querystring } = params
56
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
57
+
58
+ let path = ''
59
+ if ((index) != null && (type) != null) {
60
+ if (method == null) method = body == null ? 'GET' : 'POST'
61
+ path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_msearch' + '/' + 'template'
62
+ } else if ((index) != null) {
63
+ if (method == null) method = body == null ? 'GET' : 'POST'
64
+ path = '/' + encodeURIComponent(index) + '/' + '_msearch' + '/' + 'template'
65
+ } else {
66
+ if (method == null) method = body == null ? 'GET' : 'POST'
67
+ path = '/' + '_msearch' + '/' + 'template'
68
+ }
69
+
70
+ // build request object
71
+ const request = {
72
+ method,
73
+ path,
74
+ bulkBody: body,
75
+ querystring
76
+ }
77
+
78
+ return this.transport.request(request, options, callback)
79
+ }
80
+
81
+ module.exports = msearchTemplateApi
@@ -0,0 +1,75 @@
1
+ /*
2
+ * SPDX-License-Identifier: Apache-2.0
3
+ *
4
+ * The OpenSearch Contributors require contributions made to
5
+ * this file be licensed under the Apache-2.0 license or a
6
+ * compatible open source license.
7
+ *
8
+ * Modifications Copyright OpenSearch Contributors. See
9
+ * GitHub history for details.
10
+ */
11
+
12
+ /*
13
+ * Licensed to Elasticsearch B.V. under one or more contributor
14
+ * license agreements. See the NOTICE file distributed with
15
+ * this work for additional information regarding copyright
16
+ * ownership. Elasticsearch B.V. licenses this file to you under
17
+ * the Apache License, Version 2.0 (the "License"); you may
18
+ * not use this file except in compliance with the License.
19
+ * You may obtain a copy of the License at
20
+ *
21
+ * http://www.apache.org/licenses/LICENSE-2.0
22
+ *
23
+ * Unless required by applicable law or agreed to in writing,
24
+ * software distributed under the License is distributed on an
25
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
26
+ * KIND, either express or implied. See the License for the
27
+ * specific language governing permissions and limitations
28
+ * under the License.
29
+ */
30
+
31
+ 'use strict'
32
+
33
+ /* eslint camelcase: 0 */
34
+ /* eslint no-unused-vars: 0 */
35
+
36
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils')
37
+ const acceptedQuerystring = ['ids', 'term_statistics', 'field_statistics', 'fields', 'offsets', 'positions', 'payloads', 'preference', 'routing', 'realtime', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path']
38
+ const snakeCase = { termStatistics: 'term_statistics', fieldStatistics: 'field_statistics', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' }
39
+
40
+ function mtermvectorsApi (params, options, callback) {
41
+ ;[params, options, callback] = normalizeArguments(params, options, callback)
42
+
43
+ // check required url components
44
+ if (params.type != null && (params.index == null)) {
45
+ const err = new this[kConfigurationError]('Missing required parameter of the url: index')
46
+ return handleError(err, callback)
47
+ }
48
+
49
+ let { method, body, index, type, ...querystring } = params
50
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
51
+
52
+ let path = ''
53
+ if ((index) != null && (type) != null) {
54
+ if (method == null) method = body == null ? 'GET' : 'POST'
55
+ path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_mtermvectors'
56
+ } else if ((index) != null) {
57
+ if (method == null) method = body == null ? 'GET' : 'POST'
58
+ path = '/' + encodeURIComponent(index) + '/' + '_mtermvectors'
59
+ } else {
60
+ if (method == null) method = body == null ? 'GET' : 'POST'
61
+ path = '/' + '_mtermvectors'
62
+ }
63
+
64
+ // build request object
65
+ const request = {
66
+ method,
67
+ path,
68
+ body: body || '',
69
+ querystring
70
+ }
71
+
72
+ return this.transport.request(request, options, callback)
73
+ }
74
+
75
+ module.exports = mtermvectorsApi