@opensearch-project/opensearch 1.1.0 → 2.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 (86) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc.json +26 -0
  3. package/.prettierrc.json +5 -0
  4. package/.whitesource +15 -0
  5. package/ADMINS.md +18 -11
  6. package/COMPATIBILITY.md +24 -0
  7. package/DEVELOPER_GUIDE.md +22 -5
  8. package/MAINTAINERS.md +23 -18
  9. package/README.md +100 -101
  10. package/RELEASING.md +3 -3
  11. package/SECURITY.md +1 -1
  12. package/api/api/bulk.js +53 -26
  13. package/api/api/cat.js +354 -264
  14. package/api/api/clear_scroll.js +17 -17
  15. package/api/api/cluster.js +366 -219
  16. package/api/api/count.js +55 -24
  17. package/api/api/create.js +50 -24
  18. package/api/api/dangling_indices.js +95 -51
  19. package/api/api/delete.js +49 -22
  20. package/api/api/delete_by_query.js +88 -25
  21. package/api/api/delete_by_query_rethrottle.js +33 -19
  22. package/api/api/delete_script.js +31 -17
  23. package/api/api/exists.js +55 -22
  24. package/api/api/exists_source.js +60 -27
  25. package/api/api/explain.js +60 -22
  26. package/api/api/features.js +56 -35
  27. package/api/api/field_caps.js +36 -18
  28. package/api/api/get.js +55 -22
  29. package/api/api/get_script.js +30 -17
  30. package/api/api/get_script_context.js +15 -15
  31. package/api/api/get_script_languages.js +15 -15
  32. package/api/api/get_source.js +55 -22
  33. package/api/api/index.js +60 -28
  34. package/api/api/indices.js +1068 -857
  35. package/api/api/info.js +15 -15
  36. package/api/api/ingest.js +132 -96
  37. package/api/api/mget.js +50 -26
  38. package/api/api/msearch.js +49 -26
  39. package/api/api/msearch_template.js +53 -26
  40. package/api/api/mtermvectors.js +48 -24
  41. package/api/api/nodes.js +281 -154
  42. package/api/api/ping.js +15 -15
  43. package/api/api/put_script.js +40 -25
  44. package/api/api/rank_eval.js +37 -20
  45. package/api/api/reindex.js +38 -17
  46. package/api/api/reindex_rethrottle.js +32 -19
  47. package/api/api/render_search_template.js +18 -18
  48. package/api/api/scripts_painless_execute.js +15 -15
  49. package/api/api/scroll.js +31 -17
  50. package/api/api/search.js +108 -24
  51. package/api/api/search_shards.js +36 -18
  52. package/api/api/search_template.js +64 -26
  53. package/api/api/shutdown.js +66 -54
  54. package/api/api/snapshot.js +347 -224
  55. package/api/api/tasks.js +65 -46
  56. package/api/api/terms_enum.js +17 -17
  57. package/api/api/termvectors.js +57 -26
  58. package/api/api/update.js +64 -24
  59. package/api/api/update_by_query.js +89 -23
  60. package/api/api/update_by_query_rethrottle.js +33 -19
  61. package/api/index.js +267 -179
  62. package/api/new.d.ts +2042 -529
  63. package/api/opensearch_dashboards.d.ts +239 -236
  64. package/api/requestParams.d.ts +301 -69
  65. package/api/types.d.ts +6204 -5719
  66. package/api/utils.js +22 -22
  67. package/codecov.yml +2 -2
  68. package/index.d.ts +4776 -935
  69. package/index.js +152 -140
  70. package/index.mjs +9 -9
  71. package/lib/Connection.d.ts +37 -26
  72. package/lib/Connection.js +163 -168
  73. package/lib/Helpers.d.ts +103 -64
  74. package/lib/Helpers.js +398 -371
  75. package/lib/Serializer.d.ts +2 -2
  76. package/lib/Serializer.js +39 -39
  77. package/lib/Transport.d.ts +30 -12
  78. package/lib/Transport.js +375 -336
  79. package/lib/errors.d.ts +25 -7
  80. package/lib/errors.js +75 -71
  81. package/lib/pool/BaseConnectionPool.js +100 -97
  82. package/lib/pool/CloudConnectionPool.js +16 -16
  83. package/lib/pool/ConnectionPool.js +105 -105
  84. package/lib/pool/index.d.ts +8 -6
  85. package/lib/pool/index.js +6 -6
  86. package/package.json +13 -8
package/api/api/info.js CHANGED
@@ -28,34 +28,34 @@
28
28
  * under the License.
29
29
  */
30
30
 
31
- 'use strict'
31
+ 'use strict';
32
32
 
33
33
  /* eslint camelcase: 0 */
34
34
  /* eslint no-unused-vars: 0 */
35
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' }
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
39
 
40
- function infoApi (params, options, callback) {
41
- ;[params, options, callback] = normalizeArguments(params, options, callback)
40
+ function infoApi(params, options, callback) {
41
+ [params, options, callback] = normalizeArguments(params, options, callback);
42
42
 
43
- let { method, body, ...querystring } = params
44
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
43
+ let { method, body, ...querystring } = params;
44
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
45
45
 
46
- let path = ''
47
- if (method == null) method = 'GET'
48
- path = '/'
46
+ let path = '';
47
+ if (method == null) method = 'GET';
48
+ path = '/';
49
49
 
50
50
  // build request object
51
51
  const request = {
52
52
  method,
53
53
  path,
54
54
  body: null,
55
- querystring
56
- }
55
+ querystring,
56
+ };
57
57
 
58
- return this.transport.request(request, options, callback)
58
+ return this.transport.request(request, options, callback);
59
59
  }
60
60
 
61
- module.exports = infoApi
61
+ module.exports = infoApi;
package/api/api/ingest.js CHANGED
@@ -28,81 +28,97 @@
28
28
  * under the License.
29
29
  */
30
30
 
31
- 'use strict'
31
+ 'use strict';
32
32
 
33
33
  /* eslint camelcase: 0 */
34
34
  /* eslint no-unused-vars: 0 */
35
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
36
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
37
+ const acceptedQuerystring = [
38
+ 'cluster_manager_timeout',
39
+ 'master_timeout',
40
+ 'timeout',
41
+ 'pretty',
42
+ 'human',
43
+ 'error_trace',
44
+ 'source',
45
+ 'filter_path',
46
+ 'summary',
47
+ 'verbose',
48
+ ];
49
+ const snakeCase = {
50
+ clusterManagerTimeout: 'cluster_manager_timeout',
51
+ masterTimeout: 'master_timeout',
52
+ errorTrace: 'error_trace',
53
+ filterPath: 'filter_path',
54
+ };
55
+
56
+ function IngestApi(transport, ConfigurationError) {
57
+ this.transport = transport;
58
+ this[kConfigurationError] = ConfigurationError;
43
59
  }
44
60
 
45
- IngestApi.prototype.deletePipeline = function ingestDeletePipelineApi (params, options, callback) {
46
- ;[params, options, callback] = normalizeArguments(params, options, callback)
61
+ IngestApi.prototype.deletePipeline = function ingestDeletePipelineApi(params, options, callback) {
62
+ [params, options, callback] = normalizeArguments(params, options, callback);
47
63
 
48
64
  // check required parameters
49
65
  if (params.id == null) {
50
- const err = new this[kConfigurationError]('Missing required parameter: id')
51
- return handleError(err, callback)
66
+ const err = new this[kConfigurationError]('Missing required parameter: id');
67
+ return handleError(err, callback);
52
68
  }
53
69
 
54
- let { method, body, id, ...querystring } = params
55
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
70
+ let { method, body, id, ...querystring } = params;
71
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
56
72
 
57
- let path = ''
58
- if (method == null) method = 'DELETE'
59
- path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id)
73
+ let path = '';
74
+ if (method == null) method = 'DELETE';
75
+ path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id);
60
76
 
61
77
  // build request object
62
78
  const request = {
63
79
  method,
64
80
  path,
65
81
  body: body || '',
66
- querystring
67
- }
82
+ querystring,
83
+ };
68
84
 
69
- return this.transport.request(request, options, callback)
70
- }
85
+ return this.transport.request(request, options, callback);
86
+ };
71
87
 
72
- IngestApi.prototype.geoIpStats = function ingestGeoIpStatsApi (params, options, callback) {
73
- ;[params, options, callback] = normalizeArguments(params, options, callback)
88
+ IngestApi.prototype.geoIpStats = function ingestGeoIpStatsApi(params, options, callback) {
89
+ [params, options, callback] = normalizeArguments(params, options, callback);
74
90
 
75
- let { method, body, ...querystring } = params
76
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
91
+ let { method, body, ...querystring } = params;
92
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
77
93
 
78
- let path = ''
79
- if (method == null) method = 'GET'
80
- path = '/' + '_ingest' + '/' + 'geoip' + '/' + 'stats'
94
+ let path = '';
95
+ if (method == null) method = 'GET';
96
+ path = '/' + '_ingest' + '/' + 'geoip' + '/' + 'stats';
81
97
 
82
98
  // build request object
83
99
  const request = {
84
100
  method,
85
101
  path,
86
102
  body: null,
87
- querystring
88
- }
103
+ querystring,
104
+ };
89
105
 
90
- return this.transport.request(request, options, callback)
91
- }
106
+ return this.transport.request(request, options, callback);
107
+ };
92
108
 
93
- IngestApi.prototype.getPipeline = function ingestGetPipelineApi (params, options, callback) {
94
- ;[params, options, callback] = normalizeArguments(params, options, callback)
109
+ IngestApi.prototype.getPipeline = function ingestGetPipelineApi(params, options, callback) {
110
+ [params, options, callback] = normalizeArguments(params, options, callback);
95
111
 
96
- let { method, body, id, ...querystring } = params
97
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
112
+ let { method, body, id, ...querystring } = params;
113
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
98
114
 
99
- let path = ''
100
- if ((id) != null) {
101
- if (method == null) method = 'GET'
102
- path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id)
115
+ let path = '';
116
+ if (id != null) {
117
+ if (method == null) method = 'GET';
118
+ path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id);
103
119
  } else {
104
- if (method == null) method = 'GET'
105
- path = '/' + '_ingest' + '/' + 'pipeline'
120
+ if (method == null) method = 'GET';
121
+ path = '/' + '_ingest' + '/' + 'pipeline';
106
122
  }
107
123
 
108
124
  // build request object
@@ -110,83 +126,83 @@ IngestApi.prototype.getPipeline = function ingestGetPipelineApi (params, options
110
126
  method,
111
127
  path,
112
128
  body: null,
113
- querystring
114
- }
129
+ querystring,
130
+ };
115
131
 
116
- return this.transport.request(request, options, callback)
117
- }
132
+ return this.transport.request(request, options, callback);
133
+ };
118
134
 
119
- IngestApi.prototype.processorGrok = function ingestProcessorGrokApi (params, options, callback) {
120
- ;[params, options, callback] = normalizeArguments(params, options, callback)
135
+ IngestApi.prototype.processorGrok = function ingestProcessorGrokApi(params, options, callback) {
136
+ [params, options, callback] = normalizeArguments(params, options, callback);
121
137
 
122
- let { method, body, ...querystring } = params
123
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
138
+ let { method, body, ...querystring } = params;
139
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
124
140
 
125
- let path = ''
126
- if (method == null) method = 'GET'
127
- path = '/' + '_ingest' + '/' + 'processor' + '/' + 'grok'
141
+ let path = '';
142
+ if (method == null) method = 'GET';
143
+ path = '/' + '_ingest' + '/' + 'processor' + '/' + 'grok';
128
144
 
129
145
  // build request object
130
146
  const request = {
131
147
  method,
132
148
  path,
133
149
  body: null,
134
- querystring
135
- }
150
+ querystring,
151
+ };
136
152
 
137
- return this.transport.request(request, options, callback)
138
- }
153
+ return this.transport.request(request, options, callback);
154
+ };
139
155
 
140
- IngestApi.prototype.putPipeline = function ingestPutPipelineApi (params, options, callback) {
141
- ;[params, options, callback] = normalizeArguments(params, options, callback)
156
+ IngestApi.prototype.putPipeline = function ingestPutPipelineApi(params, options, callback) {
157
+ [params, options, callback] = normalizeArguments(params, options, callback);
142
158
 
143
159
  // check required parameters
144
160
  if (params.id == null) {
145
- const err = new this[kConfigurationError]('Missing required parameter: id')
146
- return handleError(err, callback)
161
+ const err = new this[kConfigurationError]('Missing required parameter: id');
162
+ return handleError(err, callback);
147
163
  }
148
164
  if (params.body == null) {
149
- const err = new this[kConfigurationError]('Missing required parameter: body')
150
- return handleError(err, callback)
165
+ const err = new this[kConfigurationError]('Missing required parameter: body');
166
+ return handleError(err, callback);
151
167
  }
152
168
 
153
- let { method, body, id, ...querystring } = params
154
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
169
+ let { method, body, id, ...querystring } = params;
170
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
155
171
 
156
- let path = ''
157
- if (method == null) method = 'PUT'
158
- path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id)
172
+ let path = '';
173
+ if (method == null) method = 'PUT';
174
+ path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id);
159
175
 
160
176
  // build request object
161
177
  const request = {
162
178
  method,
163
179
  path,
164
180
  body: body || '',
165
- querystring
166
- }
181
+ querystring,
182
+ };
167
183
 
168
- return this.transport.request(request, options, callback)
169
- }
184
+ return this.transport.request(request, options, callback);
185
+ };
170
186
 
171
- IngestApi.prototype.simulate = function ingestSimulateApi (params, options, callback) {
172
- ;[params, options, callback] = normalizeArguments(params, options, callback)
187
+ IngestApi.prototype.simulate = function ingestSimulateApi(params, options, callback) {
188
+ [params, options, callback] = normalizeArguments(params, options, callback);
173
189
 
174
190
  // check required parameters
175
191
  if (params.body == null) {
176
- const err = new this[kConfigurationError]('Missing required parameter: body')
177
- return handleError(err, callback)
192
+ const err = new this[kConfigurationError]('Missing required parameter: body');
193
+ return handleError(err, callback);
178
194
  }
179
195
 
180
- let { method, body, id, ...querystring } = params
181
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
196
+ let { method, body, id, ...querystring } = params;
197
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
182
198
 
183
- let path = ''
184
- if ((id) != null) {
185
- if (method == null) method = body == null ? 'GET' : 'POST'
186
- path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id) + '/' + '_simulate'
199
+ let path = '';
200
+ if (id != null) {
201
+ if (method == null) method = body == null ? 'GET' : 'POST';
202
+ path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id) + '/' + '_simulate';
187
203
  } else {
188
- if (method == null) method = body == null ? 'GET' : 'POST'
189
- path = '/' + '_ingest' + '/' + 'pipeline' + '/' + '_simulate'
204
+ if (method == null) method = body == null ? 'GET' : 'POST';
205
+ path = '/' + '_ingest' + '/' + 'pipeline' + '/' + '_simulate';
190
206
  }
191
207
 
192
208
  // build request object
@@ -194,18 +210,38 @@ IngestApi.prototype.simulate = function ingestSimulateApi (params, options, call
194
210
  method,
195
211
  path,
196
212
  body: body || '',
197
- querystring
198
- }
213
+ querystring,
214
+ };
199
215
 
200
- return this.transport.request(request, options, callback)
201
- }
216
+ return this.transport.request(request, options, callback);
217
+ };
202
218
 
203
219
  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
220
+ delete_pipeline: {
221
+ get() {
222
+ return this.deletePipeline;
223
+ },
224
+ },
225
+ geo_ip_stats: {
226
+ get() {
227
+ return this.geoIpStats;
228
+ },
229
+ },
230
+ get_pipeline: {
231
+ get() {
232
+ return this.getPipeline;
233
+ },
234
+ },
235
+ processor_grok: {
236
+ get() {
237
+ return this.processorGrok;
238
+ },
239
+ },
240
+ put_pipeline: {
241
+ get() {
242
+ return this.putPipeline;
243
+ },
244
+ },
245
+ });
246
+
247
+ module.exports = IngestApi;
package/api/api/mget.js CHANGED
@@ -28,43 +28,67 @@
28
28
  * under the License.
29
29
  */
30
30
 
31
- 'use strict'
31
+ 'use strict';
32
32
 
33
33
  /* eslint camelcase: 0 */
34
34
  /* eslint no-unused-vars: 0 */
35
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' }
36
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
37
+ const acceptedQuerystring = [
38
+ 'stored_fields',
39
+ 'preference',
40
+ 'realtime',
41
+ 'refresh',
42
+ 'routing',
43
+ '_source',
44
+ '_source_excludes',
45
+ '_source_exclude',
46
+ '_source_includes',
47
+ '_source_include',
48
+ 'pretty',
49
+ 'human',
50
+ 'error_trace',
51
+ 'source',
52
+ 'filter_path',
53
+ ];
54
+ const snakeCase = {
55
+ storedFields: 'stored_fields',
56
+ _sourceExcludes: '_source_excludes',
57
+ _sourceExclude: '_source_exclude',
58
+ _sourceIncludes: '_source_includes',
59
+ _sourceInclude: '_source_include',
60
+ errorTrace: 'error_trace',
61
+ filterPath: 'filter_path',
62
+ };
39
63
 
40
- function mgetApi (params, options, callback) {
41
- ;[params, options, callback] = normalizeArguments(params, options, callback)
64
+ function mgetApi(params, options, callback) {
65
+ [params, options, callback] = normalizeArguments(params, options, callback);
42
66
 
43
67
  // check required parameters
44
68
  if (params.body == null) {
45
- const err = new this[kConfigurationError]('Missing required parameter: body')
46
- return handleError(err, callback)
69
+ const err = new this[kConfigurationError]('Missing required parameter: body');
70
+ return handleError(err, callback);
47
71
  }
48
72
 
49
73
  // 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)
74
+ if (params.type != null && params.index == null) {
75
+ const err = new this[kConfigurationError]('Missing required parameter of the url: index');
76
+ return handleError(err, callback);
53
77
  }
54
78
 
55
- let { method, body, index, type, ...querystring } = params
56
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
79
+ let { method, body, index, type, ...querystring } = params;
80
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
57
81
 
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'
82
+ let path = '';
83
+ if (index != null && type != null) {
84
+ if (method == null) method = body == null ? 'GET' : 'POST';
85
+ path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_mget';
86
+ } else if (index != null) {
87
+ if (method == null) method = body == null ? 'GET' : 'POST';
88
+ path = '/' + encodeURIComponent(index) + '/' + '_mget';
65
89
  } else {
66
- if (method == null) method = body == null ? 'GET' : 'POST'
67
- path = '/' + '_mget'
90
+ if (method == null) method = body == null ? 'GET' : 'POST';
91
+ path = '/' + '_mget';
68
92
  }
69
93
 
70
94
  // build request object
@@ -72,10 +96,10 @@ function mgetApi (params, options, callback) {
72
96
  method,
73
97
  path,
74
98
  body: body || '',
75
- querystring
76
- }
99
+ querystring,
100
+ };
77
101
 
78
- return this.transport.request(request, options, callback)
102
+ return this.transport.request(request, options, callback);
79
103
  }
80
104
 
81
- module.exports = mgetApi
105
+ module.exports = mgetApi;
@@ -28,43 +28,66 @@
28
28
  * under the License.
29
29
  */
30
30
 
31
- 'use strict'
31
+ 'use strict';
32
32
 
33
33
  /* eslint camelcase: 0 */
34
34
  /* eslint no-unused-vars: 0 */
35
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' }
36
+ const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
37
+ const acceptedQuerystring = [
38
+ 'search_type',
39
+ 'max_concurrent_searches',
40
+ 'typed_keys',
41
+ 'pre_filter_shard_size',
42
+ 'max_concurrent_shard_requests',
43
+ 'rest_total_hits_as_int',
44
+ 'ccs_minimize_roundtrips',
45
+ 'pretty',
46
+ 'human',
47
+ 'error_trace',
48
+ 'source',
49
+ 'filter_path',
50
+ ];
51
+ const snakeCase = {
52
+ searchType: 'search_type',
53
+ maxConcurrentSearches: 'max_concurrent_searches',
54
+ typedKeys: 'typed_keys',
55
+ preFilterShardSize: 'pre_filter_shard_size',
56
+ maxConcurrentShardRequests: 'max_concurrent_shard_requests',
57
+ restTotalHitsAsInt: 'rest_total_hits_as_int',
58
+ ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips',
59
+ errorTrace: 'error_trace',
60
+ filterPath: 'filter_path',
61
+ };
39
62
 
40
- function msearchApi (params, options, callback) {
41
- ;[params, options, callback] = normalizeArguments(params, options, callback)
63
+ function msearchApi(params, options, callback) {
64
+ [params, options, callback] = normalizeArguments(params, options, callback);
42
65
 
43
66
  // check required parameters
44
67
  if (params.body == null) {
45
- const err = new this[kConfigurationError]('Missing required parameter: body')
46
- return handleError(err, callback)
68
+ const err = new this[kConfigurationError]('Missing required parameter: body');
69
+ return handleError(err, callback);
47
70
  }
48
71
 
49
72
  // 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)
73
+ if (params.type != null && params.index == null) {
74
+ const err = new this[kConfigurationError]('Missing required parameter of the url: index');
75
+ return handleError(err, callback);
53
76
  }
54
77
 
55
- let { method, body, index, type, ...querystring } = params
56
- querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring)
78
+ let { method, body, index, type, ...querystring } = params;
79
+ querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
57
80
 
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'
81
+ let path = '';
82
+ if (index != null && type != null) {
83
+ if (method == null) method = body == null ? 'GET' : 'POST';
84
+ path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_msearch';
85
+ } else if (index != null) {
86
+ if (method == null) method = body == null ? 'GET' : 'POST';
87
+ path = '/' + encodeURIComponent(index) + '/' + '_msearch';
65
88
  } else {
66
- if (method == null) method = body == null ? 'GET' : 'POST'
67
- path = '/' + '_msearch'
89
+ if (method == null) method = body == null ? 'GET' : 'POST';
90
+ path = '/' + '_msearch';
68
91
  }
69
92
 
70
93
  // build request object
@@ -72,10 +95,10 @@ function msearchApi (params, options, callback) {
72
95
  method,
73
96
  path,
74
97
  bulkBody: body,
75
- querystring
76
- }
98
+ querystring,
99
+ };
77
100
 
78
- return this.transport.request(request, options, callback)
101
+ return this.transport.request(request, options, callback);
79
102
  }
80
103
 
81
- module.exports = msearchApi
104
+ module.exports = msearchApi;