Source: api/api/indices.js

  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. * Licensed to Elasticsearch B.V. under one or more contributor
  12. * license agreements. See the NOTICE file distributed with
  13. * this work for additional information regarding copyright
  14. * ownership. Elasticsearch B.V. licenses this file to you under
  15. * the Apache License, Version 2.0 (the "License"); you may
  16. * not use this file except in compliance with the License.
  17. * You may obtain a copy of the License at
  18. *
  19. * http://www.apache.org/licenses/LICENSE-2.0
  20. *
  21. * Unless required by applicable law or agreed to in writing,
  22. * software distributed under the License is distributed on an
  23. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  24. * KIND, either express or implied. See the License for the
  25. * specific language governing permissions and limitations
  26. * under the License.
  27. */
  28. 'use strict';
  29. /** @namespace API-Index */
  30. /* eslint camelcase: 0 */
  31. /* eslint no-unused-vars: 0 */
  32. const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils');
  33. const acceptedQuerystring = [
  34. 'cluster_manager_timeout',
  35. 'timeout',
  36. 'master_timeout',
  37. 'ignore_unavailable',
  38. 'allow_no_indices',
  39. 'expand_wildcards',
  40. 'pretty',
  41. 'human',
  42. 'error_trace',
  43. 'source',
  44. 'filter_path',
  45. 'index',
  46. 'fielddata',
  47. 'fields',
  48. 'query',
  49. 'request',
  50. 'wait_for_active_shards',
  51. 'run_expensive_tasks',
  52. 'flush',
  53. 'local',
  54. 'flat_settings',
  55. 'include_defaults',
  56. 'force',
  57. 'wait_if_ongoing',
  58. 'max_num_segments',
  59. 'only_expunge_deletes',
  60. 'create',
  61. 'cause',
  62. 'write_index_only',
  63. 'preserve_existing',
  64. 'order',
  65. 'detailed',
  66. 'active_only',
  67. 'dry_run',
  68. 'verbose',
  69. 'status',
  70. 'copy_settings',
  71. 'completion_fields',
  72. 'fielddata_fields',
  73. 'groups',
  74. 'level',
  75. 'types',
  76. 'include_segment_file_sizes',
  77. 'include_unloaded_segments',
  78. 'forbid_closed_indices',
  79. 'wait_for_completion',
  80. 'only_ancient_segments',
  81. 'explain',
  82. 'q',
  83. 'analyzer',
  84. 'analyze_wildcard',
  85. 'default_operator',
  86. 'df',
  87. 'lenient',
  88. 'rewrite',
  89. 'all_shards',
  90. ];
  91. const snakeCase = {
  92. clusterManagerTimeout: 'cluster_manager_timeout',
  93. masterTimeout: 'master_timeout',
  94. ignoreUnavailable: 'ignore_unavailable',
  95. allowNoIndices: 'allow_no_indices',
  96. expandWildcards: 'expand_wildcards',
  97. errorTrace: 'error_trace',
  98. filterPath: 'filter_path',
  99. waitForActiveShards: 'wait_for_active_shards',
  100. runExpensiveTasks: 'run_expensive_tasks',
  101. flatSettings: 'flat_settings',
  102. includeDefaults: 'include_defaults',
  103. waitIfOngoing: 'wait_if_ongoing',
  104. maxNumSegments: 'max_num_segments',
  105. onlyExpungeDeletes: 'only_expunge_deletes',
  106. writeIndexOnly: 'write_index_only',
  107. preserveExisting: 'preserve_existing',
  108. activeOnly: 'active_only',
  109. dryRun: 'dry_run',
  110. copySettings: 'copy_settings',
  111. completionFields: 'completion_fields',
  112. fielddataFields: 'fielddata_fields',
  113. includeSegmentFileSizes: 'include_segment_file_sizes',
  114. includeUnloadedSegments: 'include_unloaded_segments',
  115. forbidClosedIndices: 'forbid_closed_indices',
  116. waitForCompletion: 'wait_for_completion',
  117. onlyAncientSegments: 'only_ancient_segments',
  118. analyzeWildcard: 'analyze_wildcard',
  119. defaultOperator: 'default_operator',
  120. allShards: 'all_shards',
  121. };
  122. function IndicesApi(transport, ConfigurationError) {
  123. this.transport = transport;
  124. this[kConfigurationError] = ConfigurationError;
  125. }
  126. /**
  127. * Adds a block to an index.
  128. *
  129. * @memberOf API-Index
  130. *
  131. * @param {Object} params
  132. * @param {string} params.index - A comma separated list of indices to add a block to
  133. * @param {string} params.block - The block to add (one of read, write, read_only or metadata)
  134. * @param {string} [params.timeout] - Explicit operation timeout
  135. * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
  136. * @param {boolean} [params.ignore_unavailable] - Whether specified concrete indices should be ignored when unavailable (missing or closed)
  137. * @param {boolean} [params.allow_no_indices] - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
  138. * @param {string} [params.expand_wildcards] - Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
  139. *
  140. * @param {Object} options - Options for {@link Transport#request}
  141. * @param {function} callback - Callback that handles errors and response
  142. *
  143. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  144. */
  145. IndicesApi.prototype.addBlock = function indicesAddBlockApi(params, options, callback) {
  146. [params, options, callback] = normalizeArguments(params, options, callback);
  147. // check required parameters
  148. if (params.index == null) {
  149. const err = new this[kConfigurationError]('Missing required parameter: index');
  150. return handleError(err, callback);
  151. }
  152. if (params.block == null) {
  153. const err = new this[kConfigurationError]('Missing required parameter: block');
  154. return handleError(err, callback);
  155. }
  156. // check required url components
  157. if (params.block != null && params.index == null) {
  158. const err = new this[kConfigurationError]('Missing required parameter of the url: index');
  159. return handleError(err, callback);
  160. }
  161. let { method, body, index, block, ...querystring } = params;
  162. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  163. let path = '';
  164. if (method == null) method = 'PUT';
  165. path = '/' + encodeURIComponent(index) + '/' + '_block' + '/' + encodeURIComponent(block);
  166. // build request object
  167. const request = {
  168. method,
  169. path,
  170. body: body || '',
  171. querystring,
  172. };
  173. return this.transport.request(request, options, callback);
  174. };
  175. /**
  176. * Performs the analysis process on a text and return the tokens breakdown of the text.
  177. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/analyze-apis/perform-text-analysis/ OpenSearch - Perform text analysis}
  178. *
  179. * @memberOf API-Index
  180. *
  181. * @param {Object} params
  182. * @param {string} [params.index] - The name of the index to scope the operation
  183. * @param {Object} [params.body] - Define analyzer/tokenizer parameters and the text on which the analysis should be performed
  184. *
  185. * @param {Object} 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. IndicesApi.prototype.analyze = function indicesAnalyzeApi(params, options, callback) {
  191. [params, options, callback] = normalizeArguments(params, options, callback);
  192. let { method, body, index, ...querystring } = params;
  193. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  194. let path = '';
  195. if (index != null) {
  196. if (method == null) method = body == null ? 'GET' : 'POST';
  197. path = '/' + encodeURIComponent(index) + '/' + '_analyze';
  198. } else {
  199. if (method == null) method = body == null ? 'GET' : 'POST';
  200. path = '/' + '_analyze';
  201. }
  202. // build request object
  203. const request = {
  204. method,
  205. path,
  206. body: body || '',
  207. querystring,
  208. };
  209. return this.transport.request(request, options, callback);
  210. };
  211. /**
  212. * Clears all or specific caches for one or more indices.
  213. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/index-apis/clear-index-cache/ OpenSearch - Clear index or data stream cache}
  214. *
  215. * @memberOf API-Index
  216. *
  217. * @param {Object} params
  218. * @param {string} [params.index] - A comma-separated list of index name to limit the operation
  219. * @param {boolean} [params.fielddata] - Clear field data
  220. * @param {string} [params.fields] - A comma-separated list of fields to clear when using the `fielddata` parameter (default: all)
  221. * @param {boolean} [params.query] - Clear query caches
  222. * @param {boolean} [params.ignore_unavailable] - Whether specified concrete indices should be ignored when unavailable (missing or closed)
  223. * @param {boolean} [params.allow_no_indices] - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
  224. * @param {string} [params.expand_wildcards] - Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
  225. * @param {boolean} [params.request] - Clear request cache
  226. *
  227. * @param {Object} options - Options for {@link Transport#request}
  228. * @param {function} callback - Callback that handles errors and response
  229. *
  230. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  231. */
  232. IndicesApi.prototype.clearCache = function indicesClearCacheApi(params, options, callback) {
  233. [params, options, callback] = normalizeArguments(params, options, callback);
  234. let { method, body, index, ...querystring } = params;
  235. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  236. let path = '';
  237. if (index != null) {
  238. if (method == null) method = 'POST';
  239. path = '/' + encodeURIComponent(index) + '/' + '_cache' + '/' + 'clear';
  240. } else {
  241. if (method == null) method = 'POST';
  242. path = '/' + '_cache' + '/' + 'clear';
  243. }
  244. // build request object
  245. const request = {
  246. method,
  247. path,
  248. body: body || '',
  249. querystring,
  250. };
  251. return this.transport.request(request, options, callback);
  252. };
  253. /**
  254. * Clones an index
  255. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/index-apis/clone/ OpenSearch - Clone Index}
  256. *
  257. * @memberOf API-Index
  258. *
  259. * @param {Object} params
  260. * @param {string} params.index - The name of the source index to clone
  261. * @param {string} params.target - The name of the target index to clone into
  262. * @param {string} [params.timeout] - Explicit operation timeout
  263. * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
  264. * @param {string} [params.wait_for_active_shards] - Set the number of active shards to wait for on the cloned index before the operation returns.
  265. * @param {Object} [params.body] - The configuration for the target index (`settings` and `aliases`)
  266. *
  267. * @param {Object} options - Options for {@link Transport#request}
  268. * @param {function} callback - Callback that handles errors and response
  269. *
  270. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  271. */
  272. IndicesApi.prototype.clone = function indicesCloneApi(params, options, callback) {
  273. [params, options, callback] = normalizeArguments(params, options, callback);
  274. // check required parameters
  275. if (params.index == null) {
  276. const err = new this[kConfigurationError]('Missing required parameter: index');
  277. return handleError(err, callback);
  278. }
  279. if (params.target == null) {
  280. const err = new this[kConfigurationError]('Missing required parameter: target');
  281. return handleError(err, callback);
  282. }
  283. // check required url components
  284. if (params.target != null && params.index == null) {
  285. const err = new this[kConfigurationError]('Missing required parameter of the url: index');
  286. return handleError(err, callback);
  287. }
  288. let { method, body, index, target, ...querystring } = params;
  289. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  290. let path = '';
  291. if (method == null) method = 'PUT';
  292. path = '/' + encodeURIComponent(index) + '/' + '_clone' + '/' + encodeURIComponent(target);
  293. // build request object
  294. const request = {
  295. method,
  296. path,
  297. body: body || '',
  298. querystring,
  299. };
  300. return this.transport.request(request, options, callback);
  301. };
  302. /**
  303. * Closes an index.
  304. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/index-apis/close-index/ OpenSearch - Close Index}
  305. *
  306. * @memberOf API-Index
  307. *
  308. * @param {Object} params
  309. * @param {string} params.index - A comma separated list of indices to close
  310. * @param {string} [params.timeout] - Explicit operation timeout
  311. * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
  312. * @param {boolean} [params.ignore_unavailable] - Whether specified concrete indices should be ignored when unavailable (missing or closed)
  313. * @param {boolean} [params.allow_no_indices] - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
  314. * @param {string} [params.expand_wildcards] - Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
  315. * @param {string} [params.wait_for_active_shards] - Sets the number of active shards to wait for before the operation returns. Set to `index-setting` to wait according to the index setting `index.write.wait_for_active_shards`, or `all` to wait for all shards, or an integer. Defaults to `0`.
  316. *
  317. * @param {Object} options - Options for {@link Transport#request}
  318. * @param {function} callback - Callback that handles errors and response
  319. *
  320. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  321. */
  322. IndicesApi.prototype.close = function indicesCloseApi(params, options, callback) {
  323. [params, options, callback] = normalizeArguments(params, options, callback);
  324. // check required parameters
  325. if (params.index == null) {
  326. const err = new this[kConfigurationError]('Missing required parameter: index');
  327. return handleError(err, callback);
  328. }
  329. let { method, body, index, ...querystring } = params;
  330. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  331. let path = '';
  332. if (method == null) method = 'POST';
  333. path = '/' + encodeURIComponent(index) + '/' + '_close';
  334. // build request object
  335. const request = {
  336. method,
  337. path,
  338. body: body || '',
  339. querystring,
  340. };
  341. return this.transport.request(request, options, callback);
  342. };
  343. /**
  344. * Creates an index
  345. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/index-apis/create-index/ OpenSearch - Create Index}
  346. *
  347. * @memberOf API-Index
  348. *
  349. * @param {Object} params
  350. * @param {string} params.index - Name of the index.
  351. * @param {Object} [params.body] - The configuration for the index (`settings` and `mappings`)
  352. * @param {string} [params.wait_for_active_shards] - Set the number of active shards to wait for before the operation returns.
  353. * @param {string} [params.timeout] - Explicit operation timeout
  354. * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
  355. *
  356. * @param {Object} options - Options for {@link Transport#request}
  357. * @param {function} callback - Callback that handles errors and response
  358. *
  359. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  360. */
  361. IndicesApi.prototype.create = function indicesCreateApi(params, options, callback) {
  362. [params, options, callback] = normalizeArguments(params, options, callback);
  363. // check required parameters
  364. if (params.index == null) {
  365. const err = new this[kConfigurationError]('Missing required parameter: index');
  366. return handleError(err, callback);
  367. }
  368. let { method, body, index, ...querystring } = params;
  369. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  370. let path = '';
  371. if (method == null) method = 'PUT';
  372. path = '/' + encodeURIComponent(index);
  373. // build request object
  374. const request = {
  375. method,
  376. path,
  377. body: body || '',
  378. querystring,
  379. };
  380. return this.transport.request(request, options, callback);
  381. };
  382. /**
  383. * Deletes an index.
  384. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/index-apis/delete-index/ OpenSearch - Delete Index}
  385. *
  386. * @memberOf API-Index
  387. *
  388. * @param {Object} params
  389. * @param {string} params.index - A comma-separated list of indices to delete; use `_all` or `*` string to delete all indices
  390. * @param {string} [params.timeout] - Explicit operation timeout
  391. * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
  392. * @param {boolean} [params.ignore_unavailable=false] - Ignore unavailable indexes
  393. * @param {boolean} [params.allow_no_indices=false] - Ignore if a wildcard expression resolves to no concrete indices
  394. * @param {string} [params.expand_wildcards=open] - Whether wildcard expressions should get expanded to open or closed indices (options: open, closed, hidden, none, all)
  395. *
  396. * @param {Object} options - Options for {@link Transport#request}
  397. * @param {function} callback - Callback that handles errors and response
  398. *
  399. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  400. */
  401. IndicesApi.prototype.delete = function indicesDeleteApi(params, options, callback) {
  402. [params, options, callback] = normalizeArguments(params, options, callback);
  403. // check required parameters
  404. if (params.index == null) {
  405. const err = new this[kConfigurationError]('Missing required parameter: index');
  406. return handleError(err, callback);
  407. }
  408. let { method, body, index, ...querystring } = params;
  409. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  410. let path = '';
  411. if (method == null) method = 'DELETE';
  412. path = '/' + encodeURIComponent(index);
  413. // build request object
  414. const request = {
  415. method,
  416. path,
  417. body: body || '',
  418. querystring,
  419. };
  420. return this.transport.request(request, options, callback);
  421. };
  422. /**
  423. * Deletes an alias.
  424. * <br/> See Also: {@link https://opensearch.org/docs/latest/opensearch/index-alias/ OpenSearch - Index Aliases}
  425. *
  426. * @memberOf API-Index
  427. *
  428. * @param {Object} params
  429. * @param {string} params.index - A comma-separated list of index names (supports wildcards); use `_all` for all indices
  430. * @param {string} params.name - A comma-separated list of aliases to delete (supports wildcards); use `_all` to delete all aliases for the specified indices.
  431. * @param {string} [params.timeout] - Explicit timestamp for the document
  432. * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
  433. *
  434. * @param {Object} options - Options for {@link Transport#request}
  435. * @param {function} callback - Callback that handles errors and response
  436. *
  437. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  438. */
  439. IndicesApi.prototype.deleteAlias = function indicesDeleteAliasApi(params, options, callback) {
  440. [params, options, callback] = normalizeArguments(params, options, callback);
  441. // check required parameters
  442. if (params.index == null) {
  443. const err = new this[kConfigurationError]('Missing required parameter: index');
  444. return handleError(err, callback);
  445. }
  446. if (params.name == null) {
  447. const err = new this[kConfigurationError]('Missing required parameter: name');
  448. return handleError(err, callback);
  449. }
  450. // check required url components
  451. if (params.name != null && params.index == null) {
  452. const err = new this[kConfigurationError]('Missing required parameter of the url: index');
  453. return handleError(err, callback);
  454. }
  455. let { method, body, index, name, ...querystring } = params;
  456. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  457. let path = '';
  458. if (index != null && name != null) {
  459. if (method == null) method = 'DELETE';
  460. path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name);
  461. } else {
  462. if (method == null) method = 'DELETE';
  463. path = '/' + encodeURIComponent(index) + '/' + '_aliases' + '/' + encodeURIComponent(name);
  464. }
  465. // build request object
  466. const request = {
  467. method,
  468. path,
  469. body: body || '',
  470. querystring,
  471. };
  472. return this.transport.request(request, options, callback);
  473. };
  474. /**
  475. * Deletes an index template.
  476. * <br/> See Also: {@link https://opensearch.org/docs/latest/opensearch/index-templates/ OpenSearch - Index Templates}
  477. *
  478. * @memberOf API-Index
  479. *
  480. * @param {Object} params
  481. * @param {string} params.name - The name of the template
  482. * @param {string} [params.timeout] - Explicit operation timeout
  483. * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
  484. *
  485. * @param {Object} options - Options for {@link Transport#request}
  486. * @param {function} callback - Callback that handles errors and response
  487. *
  488. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  489. */
  490. IndicesApi.prototype.deleteIndexTemplate = function indicesDeleteIndexTemplateApi(
  491. params,
  492. options,
  493. callback
  494. ) {
  495. [params, options, callback] = normalizeArguments(params, options, callback);
  496. // check required parameters
  497. if (params.name == null) {
  498. const err = new this[kConfigurationError]('Missing required parameter: name');
  499. return handleError(err, callback);
  500. }
  501. let { method, body, name, ...querystring } = params;
  502. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  503. let path = '';
  504. if (method == null) method = 'DELETE';
  505. path = '/' + '_index_template' + '/' + encodeURIComponent(name);
  506. // build request object
  507. const request = {
  508. method,
  509. path,
  510. body: body || '',
  511. querystring,
  512. };
  513. return this.transport.request(request, options, callback);
  514. };
  515. /**
  516. * Deletes an index template (Deprecated. Use IndicesApi#deleteIndexTemplate instead)
  517. *
  518. * @memberOf API-Index
  519. *
  520. * @param {Object} params
  521. * @param {string} params.name - The name of the template
  522. * @param {string} [params.timeout] - Explicit operation timeout
  523. * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
  524. *
  525. * @param {Object} options - Options for {@link Transport#request}
  526. * @param {function} callback - Callback that handles errors and response
  527. *
  528. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  529. */
  530. IndicesApi.prototype.deleteTemplate = function indicesDeleteTemplateApi(params, options, callback) {
  531. [params, options, callback] = normalizeArguments(params, options, callback);
  532. // check required parameters
  533. if (params.name == null) {
  534. const err = new this[kConfigurationError]('Missing required parameter: name');
  535. return handleError(err, callback);
  536. }
  537. let { method, body, name, ...querystring } = params;
  538. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  539. let path = '';
  540. if (method == null) method = 'DELETE';
  541. path = '/' + '_template' + '/' + encodeURIComponent(name);
  542. // build request object
  543. const request = {
  544. method,
  545. path,
  546. body: body || '',
  547. querystring,
  548. };
  549. return this.transport.request(request, options, callback);
  550. };
  551. // TODO: Remove. Experimental feature added in ES 7.15
  552. IndicesApi.prototype.diskUsage = function indicesDiskUsageApi(params, options, callback) {
  553. [params, options, callback] = normalizeArguments(params, options, callback);
  554. // check required parameters
  555. if (params.index == null) {
  556. const err = new this[kConfigurationError]('Missing required parameter: index');
  557. return handleError(err, callback);
  558. }
  559. let { method, body, index, ...querystring } = params;
  560. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  561. let path = '';
  562. if (method == null) method = 'POST';
  563. path = '/' + encodeURIComponent(index) + '/' + '_disk_usage';
  564. // build request object
  565. const request = {
  566. method,
  567. path,
  568. body: body || '',
  569. querystring,
  570. };
  571. return this.transport.request(request, options, callback);
  572. };
  573. /**
  574. * Returns information about whether a particular index exists.
  575. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/index-apis/exists/ OpenSearch - Index Exists}
  576. *
  577. * @memberOf API-Index
  578. *
  579. * @param {Object} params
  580. * @param {string} params.index - A comma-separated list of index names
  581. * @param {boolean} [params.local=false] - Return local information, do not retrieve the state from cluster_manager node
  582. * @param {boolean} [params.ignore_unavailable=false] - Ignore unavailable indexes
  583. * @param {boolean} [params.allow_no_indices=false] - Ignore if a wildcard expression resolves to no concrete indices
  584. * @param {string} [params.expand_wildcards=open] - Whether wildcard expressions should get expanded to open or closed indices (options: open, closed, hidden, none, all)
  585. * @param {boolean} [params.flat_settings=false] - Return settings in flat format
  586. * @param {boolean} [params.include_defaults] - Whether to return all default setting for each of the indices.
  587. *
  588. * @param {Object} options - Options for {@link Transport#request}
  589. * @param {function} callback - Callback that handles errors and response
  590. *
  591. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  592. */
  593. IndicesApi.prototype.exists = function indicesExistsApi(params, options, callback) {
  594. [params, options, callback] = normalizeArguments(params, options, callback);
  595. // check required parameters
  596. if (params.index == null) {
  597. const err = new this[kConfigurationError]('Missing required parameter: index');
  598. return handleError(err, callback);
  599. }
  600. let { method, body, index, ...querystring } = params;
  601. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  602. let path = '';
  603. if (method == null) method = 'HEAD';
  604. path = '/' + encodeURIComponent(index);
  605. // build request object
  606. const request = {
  607. method,
  608. path,
  609. body: null,
  610. querystring,
  611. };
  612. return this.transport.request(request, options, callback);
  613. };
  614. /**
  615. * Returns information about whether a particular alias exists.
  616. * <br/> See Also: {@link https://opensearch.org/docs/latest/opensearch/index-alias/ OpenSearch - Index Aliases}
  617. *
  618. * @memberOf API-Index
  619. *
  620. * @param {Object} params
  621. * @param {string} params.name - A comma-separated list of alias names to return
  622. * @param {string} [params.index] - A comma-separated list of index names to filter aliases
  623. * @param {boolean} [params.ignore_unavailable] - Whether specified concrete indices should be ignored when unavailable (missing or closed)
  624. * @param {boolean} [params.allow_no_indices] - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
  625. * @param {string} [params.expand_wildcards] - Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
  626. * @param {boolean} [params.local=false] - Return local information, do not retrieve the state from cluster_manager node
  627. *
  628. * @param {Object} options - Options for {@link Transport#request}
  629. * @param {function} callback - Callback that handles errors and response
  630. *
  631. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  632. */
  633. IndicesApi.prototype.existsAlias = function indicesExistsAliasApi(params, options, callback) {
  634. [params, options, callback] = normalizeArguments(params, options, callback);
  635. // check required parameters
  636. if (params.name == null) {
  637. const err = new this[kConfigurationError]('Missing required parameter: name');
  638. return handleError(err, callback);
  639. }
  640. let { method, body, name, index, ...querystring } = params;
  641. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  642. let path = '';
  643. if (index != null && name != null) {
  644. if (method == null) method = 'HEAD';
  645. path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name);
  646. } else {
  647. if (method == null) method = 'HEAD';
  648. path = '/' + '_alias' + '/' + encodeURIComponent(name);
  649. }
  650. // build request object
  651. const request = {
  652. method,
  653. path,
  654. body: null,
  655. querystring,
  656. };
  657. return this.transport.request(request, options, callback);
  658. };
  659. /**
  660. * Returns information about whether a particular index template exists.
  661. * <br/> See Also: {@link https://opensearch.org/docs/latest/opensearch/index-templates/ OpenSearch - Index Templates}
  662. *
  663. * @memberOf API-Index
  664. *
  665. * @param {Object} params
  666. * @param {string} params.name - The name of the template
  667. * @param {boolean} [params.flat_settings=false] - Return settings in flat format
  668. * @param {string} [params.cluster_manager_timeout] - Explicit operation timeout for connection to cluster_manager node
  669. * @param {boolean} [params.local=false] - Return local information, do not retrieve the state from cluster_manager node
  670. *
  671. * @param {Object} options - Options for {@link Transport#request}
  672. * @param {function} callback - Callback that handles errors and response
  673. *
  674. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  675. */
  676. IndicesApi.prototype.existsIndexTemplate = function indicesExistsIndexTemplateApi(
  677. params,
  678. options,
  679. callback
  680. ) {
  681. [params, options, callback] = normalizeArguments(params, options, callback);
  682. // check required parameters
  683. if (params.name == null) {
  684. const err = new this[kConfigurationError]('Missing required parameter: name');
  685. return handleError(err, callback);
  686. }
  687. let { method, body, name, ...querystring } = params;
  688. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  689. let path = '';
  690. if (method == null) method = 'HEAD';
  691. path = '/' + '_index_template' + '/' + encodeURIComponent(name);
  692. // build request object
  693. const request = {
  694. method,
  695. path,
  696. body: null,
  697. querystring,
  698. };
  699. return this.transport.request(request, options, callback);
  700. };
  701. /**
  702. * Returns information about whether a particular index template exists. (Deprecated. Use IndicesApi#existsIndexTemplate instead)
  703. *
  704. * @memberOf API-Index
  705. *
  706. * @param {Object} params
  707. * @param {string} params.name - The comma separated names of the index templates
  708. * @param {boolean} [params.flat_settings=false] - Return settings in flat format
  709. * @param {string} [params.cluster_manager_timeout] - Explicit operation timeout for connection to cluster_manager node
  710. * @param {boolean} [params.local=false] - Return local information, do not retrieve the state from cluster_manager node
  711. *
  712. * @param {Object} options - Options for {@link Transport#request}
  713. * @param {function} callback - Callback that handles errors and response
  714. *
  715. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  716. */
  717. IndicesApi.prototype.existsTemplate = function indicesExistsTemplateApi(params, options, callback) {
  718. [params, options, callback] = normalizeArguments(params, options, callback);
  719. // check required parameters
  720. if (params.name == null) {
  721. const err = new this[kConfigurationError]('Missing required parameter: name');
  722. return handleError(err, callback);
  723. }
  724. let { method, body, name, ...querystring } = params;
  725. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  726. let path = '';
  727. if (method == null) method = 'HEAD';
  728. path = '/' + '_template' + '/' + encodeURIComponent(name);
  729. // build request object
  730. const request = {
  731. method,
  732. path,
  733. body: null,
  734. querystring,
  735. };
  736. return this.transport.request(request, options, callback);
  737. };
  738. // TODO: Remove. Experimental feature added in ES 7.15
  739. IndicesApi.prototype.fieldUsageStats = function indicesFieldUsageStatsApi(
  740. params,
  741. options,
  742. callback
  743. ) {
  744. [params, options, callback] = normalizeArguments(params, options, callback);
  745. // check required parameters
  746. if (params.index == null) {
  747. const err = new this[kConfigurationError]('Missing required parameter: index');
  748. return handleError(err, callback);
  749. }
  750. let { method, body, index, ...querystring } = params;
  751. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  752. let path = '';
  753. if (method == null) method = 'GET';
  754. path = '/' + encodeURIComponent(index) + '/' + '_field_usage_stats';
  755. // build request object
  756. const request = {
  757. method,
  758. path,
  759. body: null,
  760. querystring,
  761. };
  762. return this.transport.request(request, options, callback);
  763. };
  764. /**
  765. * Performs the flush operation on one or more indices.
  766. *
  767. * @memberOf API-Index
  768. *
  769. * @param {Object} params
  770. * @param {string} [params.index] - A comma-separated list of index names; use `_all` or empty string for all indices
  771. * @param {boolean} [params.force] - Whether a flush should be forced even if it is not necessarily needed ie. if no changes will be committed to the index. This is useful if transaction log IDs should be incremented even if no uncommitted changes are present. (This setting can be considered as internal)
  772. * @param {boolean} [params.wait_if_ongoing=true] - If set to true the flush operation will block until the flush can be executed if another flush operation is already executing. If set to false the flush will be skipped iff if another flush operation is already running.
  773. * @param {boolean} [params.ignore_unavailable] - Whether specified concrete indices should be ignored when unavailable (missing or closed)
  774. * @param {boolean} [params.allow_no_indices] - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
  775. * @param {string} [params.expand_wildcards] - Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
  776. *
  777. * @param {Object} options - Options for {@link Transport#request}
  778. * @param {function} callback - Callback that handles errors and response
  779. *
  780. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  781. */
  782. IndicesApi.prototype.flush = function indicesFlushApi(params, options, callback) {
  783. [params, options, callback] = normalizeArguments(params, options, callback);
  784. let { method, body, index, ...querystring } = params;
  785. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  786. let path = '';
  787. if (index != null) {
  788. if (method == null) method = body == null ? 'GET' : 'POST';
  789. path = '/' + encodeURIComponent(index) + '/' + '_flush';
  790. } else {
  791. if (method == null) method = body == null ? 'GET' : 'POST';
  792. path = '/' + '_flush';
  793. }
  794. // build request object
  795. const request = {
  796. method,
  797. path,
  798. body: body || '',
  799. querystring,
  800. };
  801. return this.transport.request(request, options, callback);
  802. };
  803. /**
  804. * Performs the force merge operation on one or more indices.
  805. *
  806. * @memberOf API-Index
  807. *
  808. * @param {Object} params
  809. * @param {string} [params.index] - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
  810. * @param {boolean} [params.flush=true] - Specify whether the index should be flushed after performing the operation
  811. * @param {boolean} [params.ignore_unavailable] - Whether specified concrete indices should be ignored when unavailable (missing or closed)
  812. * @param {boolean} [params.allow_no_indices] - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
  813. * @param {string} [params.expand_wildcards] - Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
  814. * @param {number} [params.max_num_segments] - The number of segments the index should be merged into (default: dynamic)
  815. * @param {boolean} [params.only_expunge_deletes] - Specify whether the operation should only expunge deleted documents
  816. *
  817. * @param {Object} options - Options for {@link Transport#request}
  818. * @param {function} callback - Callback that handles errors and response
  819. *
  820. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  821. */
  822. IndicesApi.prototype.forcemerge = function indicesForcemergeApi(params, options, callback) {
  823. [params, options, callback] = normalizeArguments(params, options, callback);
  824. let { method, body, index, ...querystring } = params;
  825. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  826. let path = '';
  827. if (index != null) {
  828. if (method == null) method = 'POST';
  829. path = '/' + encodeURIComponent(index) + '/' + '_forcemerge';
  830. } else {
  831. if (method == null) method = 'POST';
  832. path = '/' + '_forcemerge';
  833. }
  834. // build request object
  835. const request = {
  836. method,
  837. path,
  838. body: body || '',
  839. querystring,
  840. };
  841. return this.transport.request(request, options, callback);
  842. };
  843. /**
  844. * Returns information about one or more indices.
  845. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/index-apis/get-index/ OpenSearch - Get Index}
  846. *
  847. * @memberOf API-Index
  848. *
  849. * @param {Object} params
  850. * @param {string} params.index - A comma-separated list of index names
  851. * @param {boolean} [params.local=false] - Return local information, do not retrieve the state from cluster_manager node
  852. * @param {boolean} [params.ignore_unavailable=false] - Ignore unavailable indexes
  853. * @param {boolean} [params.allow_no_indices=false] - Ignore if a wildcard expression resolves to no concrete indices
  854. * @param {string} [params.expand_wildcards=open] - Whether wildcard expressions should get expanded to open or closed indices (options: open, closed, hidden, none, all)
  855. * @param {boolean} [params.flat_settings=false] - Return settings in flat format
  856. * @param {boolean} [params.include_defaults] - Whether to return all default setting for each of the indices.
  857. * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
  858. *
  859. * @param {Object} options - Options for {@link Transport#request}
  860. * @param {function} callback - Callback that handles errors and response
  861. *
  862. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  863. */
  864. IndicesApi.prototype.get = function indicesGetApi(params, options, callback) {
  865. [params, options, callback] = normalizeArguments(params, options, callback);
  866. // check required parameters
  867. if (params.index == null) {
  868. const err = new this[kConfigurationError]('Missing required parameter: index');
  869. return handleError(err, callback);
  870. }
  871. let { method, body, index, ...querystring } = params;
  872. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  873. let path = '';
  874. if (method == null) method = 'GET';
  875. path = '/' + encodeURIComponent(index);
  876. // build request object
  877. const request = {
  878. method,
  879. path,
  880. body: null,
  881. querystring,
  882. };
  883. return this.transport.request(request, options, callback);
  884. };
  885. /**
  886. * Returns an alias.
  887. * <br/> See Also: {@link https://opensearch.org/docs/latest/opensearch/index-alias/ OpenSearch - Index Aliases}
  888. *
  889. * @memberOf API-Index
  890. *
  891. * @param {Object} params
  892. * @param {string} [params.name] - A comma-separated list of alias names to return
  893. * @param {string} [params.index] - A comma-separated list of index names to filter aliases
  894. * @param {boolean} [params.ignore_unavailable] - Whether specified concrete indices should be ignored when unavailable (missing or closed)
  895. * @param {boolean} [params.allow_no_indices] - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
  896. * @param {string} [params.expand_wildcards] - Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
  897. * @param {boolean} [params.local=false] - Return local information, do not retrieve the state from cluster_manager node
  898. *
  899. * @param {Object} options - Options for {@link Transport#request}
  900. * @param {function} callback - Callback that handles errors and response
  901. *
  902. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  903. */
  904. IndicesApi.prototype.getAlias = function indicesGetAliasApi(params, options, callback) {
  905. [params, options, callback] = normalizeArguments(params, options, callback);
  906. let { method, body, name, index, ...querystring } = params;
  907. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  908. let path = '';
  909. if (index != null && name != null) {
  910. if (method == null) method = 'GET';
  911. path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name);
  912. } else if (name != null) {
  913. if (method == null) method = 'GET';
  914. path = '/' + '_alias' + '/' + encodeURIComponent(name);
  915. } else if (index != null) {
  916. if (method == null) method = 'GET';
  917. path = '/' + encodeURIComponent(index) + '/' + '_alias';
  918. } else {
  919. if (method == null) method = 'GET';
  920. path = '/' + '_alias';
  921. }
  922. // build request object
  923. const request = {
  924. method,
  925. path,
  926. body: null,
  927. querystring,
  928. };
  929. return this.transport.request(request, options, callback);
  930. };
  931. /**
  932. * Returns mapping for one or more fields.
  933. * <br/> See Also: {@link https://opensearch.org/docs/latest/opensearch/mappings/ OpenSearch - Mapping}
  934. *
  935. * @memberOf API-Index
  936. *
  937. * @param {Object} params
  938. * @param {string} params.fields - A comma-separated list of fields
  939. * @param {string} [params.index] - A comma-separated list of index names
  940. * @param {boolean} [params.include_defaults] - Whether the default mapping values should be returned as well
  941. * @param {boolean} [params.ignore_unavailable] - Whether specified concrete indices should be ignored when unavailable (missing or closed)
  942. * @param {boolean} [params.allow_no_indices] - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
  943. * @param {string} [params.expand_wildcards] - Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
  944. * @param {boolean} [params.local=false] - Return local information, do not retrieve the state from cluster_manager node
  945. *
  946. * @param {Object} options - Options for {@link Transport#request}
  947. * @param {function} callback - Callback that handles errors and response
  948. *
  949. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  950. */
  951. IndicesApi.prototype.getFieldMapping = function indicesGetFieldMappingApi(
  952. params,
  953. options,
  954. callback
  955. ) {
  956. [params, options, callback] = normalizeArguments(params, options, callback);
  957. // check required parameters
  958. if (params.fields == null) {
  959. const err = new this[kConfigurationError]('Missing required parameter: fields');
  960. return handleError(err, callback);
  961. }
  962. let { method, body, fields, index, type, ...querystring } = params;
  963. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  964. let path = '';
  965. if (index != null && type != null && fields != null) {
  966. if (method == null) method = 'GET';
  967. path =
  968. '/' +
  969. encodeURIComponent(index) +
  970. '/' +
  971. '_mapping' +
  972. '/' +
  973. encodeURIComponent(type) +
  974. '/' +
  975. 'field' +
  976. '/' +
  977. encodeURIComponent(fields);
  978. } else if (index != null && fields != null) {
  979. if (method == null) method = 'GET';
  980. path =
  981. '/' +
  982. encodeURIComponent(index) +
  983. '/' +
  984. '_mapping' +
  985. '/' +
  986. 'field' +
  987. '/' +
  988. encodeURIComponent(fields);
  989. } else if (type != null && fields != null) {
  990. if (method == null) method = 'GET';
  991. path =
  992. '/' +
  993. '_mapping' +
  994. '/' +
  995. encodeURIComponent(type) +
  996. '/' +
  997. 'field' +
  998. '/' +
  999. encodeURIComponent(fields);
  1000. } else {
  1001. if (method == null) method = 'GET';
  1002. path = '/' + '_mapping' + '/' + 'field' + '/' + encodeURIComponent(fields);
  1003. }
  1004. // build request object
  1005. const request = {
  1006. method,
  1007. path,
  1008. body: null,
  1009. querystring,
  1010. };
  1011. return this.transport.request(request, options, callback);
  1012. };
  1013. /**
  1014. * Returns an index template.
  1015. * <br/> See Also: {@link https://opensearch.org/docs/latest/opensearch/index-templates/ OpenSearch - Index Templates}
  1016. *
  1017. * @memberOf API-Index
  1018. *
  1019. * @param {Object} params
  1020. * @param {string} [params.name] - The comma separated names of the index templates
  1021. * @param {boolean} [params.flat_setting=false] - Return settings in flat format
  1022. * @param {string} [params.cluster_manager_timeout] - Explicit operation timeout for connection to cluster_manager node
  1023. * @param {boolean} [params.local=false] - Return local information, do not retrieve the state from cluster_manager node
  1024. *
  1025. * @param {Object} options - Options for {@link Transport#request}
  1026. * @param {function} callback - Callback that handles errors and response
  1027. *
  1028. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1029. */
  1030. IndicesApi.prototype.getIndexTemplate = function indicesGetIndexTemplateApi(
  1031. params,
  1032. options,
  1033. callback
  1034. ) {
  1035. [params, options, callback] = normalizeArguments(params, options, callback);
  1036. let { method, body, name, ...querystring } = params;
  1037. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  1038. let path = '';
  1039. if (name != null) {
  1040. if (method == null) method = 'GET';
  1041. path = '/' + '_index_template' + '/' + encodeURIComponent(name);
  1042. } else {
  1043. if (method == null) method = 'GET';
  1044. path = '/' + '_index_template';
  1045. }
  1046. // build request object
  1047. const request = {
  1048. method,
  1049. path,
  1050. body: null,
  1051. querystring,
  1052. };
  1053. return this.transport.request(request, options, callback);
  1054. };
  1055. /**
  1056. * Returns mappings for one or more indices.
  1057. * <br/> See Also: {@link https://opensearch.org/docs/latest/opensearch/mappings/ OpenSearch - Mapping}
  1058. *
  1059. * @memberOf API-Index
  1060. *
  1061. * @param {Object} params
  1062. * @param {string} [params.index] - A comma-separated list of index names
  1063. * @param {boolean} [params.ignore_unavailable] - Whether specified concrete indices should be ignored when unavailable (missing or closed)
  1064. * @param {boolean} [params.allow_no_indices] - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
  1065. * @param {string} [params.expand_wildcards] - Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
  1066. * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
  1067. * @param {boolean} [params.local=false] - Return local information, do not retrieve the state from cluster_manager node (Deprecated)
  1068. *
  1069. * @param {Object} options - Options for {@link Transport#request}
  1070. * @param {function} callback - Callback that handles errors and response
  1071. *
  1072. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1073. */
  1074. IndicesApi.prototype.getMapping = function indicesGetMappingApi(params, options, callback) {
  1075. [params, options, callback] = normalizeArguments(params, options, callback);
  1076. let { method, body, index, type, ...querystring } = params;
  1077. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  1078. let path = '';
  1079. if (index != null && type != null) {
  1080. if (method == null) method = 'GET';
  1081. path = '/' + encodeURIComponent(index) + '/' + '_mapping' + '/' + encodeURIComponent(type);
  1082. } else if (index != null) {
  1083. if (method == null) method = 'GET';
  1084. path = '/' + encodeURIComponent(index) + '/' + '_mapping';
  1085. } else if (type != null) {
  1086. if (method == null) method = 'GET';
  1087. path = '/' + '_mapping' + '/' + encodeURIComponent(type);
  1088. } else {
  1089. if (method == null) method = 'GET';
  1090. path = '/' + '_mapping';
  1091. }
  1092. // build request object
  1093. const request = {
  1094. method,
  1095. path,
  1096. body: null,
  1097. querystring,
  1098. };
  1099. return this.transport.request(request, options, callback);
  1100. };
  1101. /**
  1102. * Returns settings for one or more indices.
  1103. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/index-apis/get-settings/ OpenSearch - Get Settings}
  1104. *
  1105. * @memberOf API-Index
  1106. *
  1107. * @param {Object} params
  1108. * @param {string} [params.index] - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
  1109. * @param {string} [params.name] - The name of the settings that should be included
  1110. * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
  1111. * @param {boolean} [params.ignore_unavailable] - Whether specified concrete indices should be ignored when unavailable (missing or closed)
  1112. * @param {boolean} [params.allow_no_indices] - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
  1113. * @param {string} [params.expand_wildcards] - Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
  1114. * @param {boolean} [params.flat_settings=false] - Return settings in flat format
  1115. * @param {boolean} [params.local=false] - Return local information, do not retrieve the state from cluster_manager node
  1116. * @param {boolean} [params.include_defaults] - Whether to return all default setting for each of the indices.
  1117. *
  1118. * @param {Object} options - Options for {@link Transport#request}
  1119. * @param {function} callback - Callback that handles errors and response
  1120. *
  1121. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1122. */
  1123. IndicesApi.prototype.getSettings = function indicesGetSettingsApi(params, options, callback) {
  1124. [params, options, callback] = normalizeArguments(params, options, callback);
  1125. let { method, body, index, name, ...querystring } = params;
  1126. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  1127. let path = '';
  1128. if (index != null && name != null) {
  1129. if (method == null) method = 'GET';
  1130. path = '/' + encodeURIComponent(index) + '/' + '_settings' + '/' + encodeURIComponent(name);
  1131. } else if (index != null) {
  1132. if (method == null) method = 'GET';
  1133. path = '/' + encodeURIComponent(index) + '/' + '_settings';
  1134. } else if (name != null) {
  1135. if (method == null) method = 'GET';
  1136. path = '/' + '_settings' + '/' + encodeURIComponent(name);
  1137. } else {
  1138. if (method == null) method = 'GET';
  1139. path = '/' + '_settings';
  1140. }
  1141. // build request object
  1142. const request = {
  1143. method,
  1144. path,
  1145. body: null,
  1146. querystring,
  1147. };
  1148. return this.transport.request(request, options, callback);
  1149. };
  1150. /**
  1151. * Returns an index template. (Deprecated. Use IndicesApi#getIndexTemplate instead)
  1152. *
  1153. * @memberOf API-Index
  1154. *
  1155. * @param {Object} params
  1156. * @param {string} [params.name] - The comma separated names of the index templates
  1157. * @param {boolean} [params.flat_settings=false] - Return settings in flat format
  1158. * @param {string} [params.cluster_manager_timeout] - Explicit operation timeout for connection to cluster_manager node
  1159. * @param {boolean} [params.local=false] - Return local information, do not retrieve the state from cluster_manager node
  1160. *
  1161. * @param {Object} options - Options for {@link Transport#request}
  1162. * @param {function} callback - Callback that handles errors and response
  1163. *
  1164. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1165. */
  1166. IndicesApi.prototype.getTemplate = function indicesGetTemplateApi(params, options, callback) {
  1167. [params, options, callback] = normalizeArguments(params, options, callback);
  1168. let { method, body, name, ...querystring } = params;
  1169. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  1170. let path = '';
  1171. if (name != null) {
  1172. if (method == null) method = 'GET';
  1173. path = '/' + '_template' + '/' + encodeURIComponent(name);
  1174. } else {
  1175. if (method == null) method = 'GET';
  1176. path = '/' + '_template';
  1177. }
  1178. // build request object
  1179. const request = {
  1180. method,
  1181. path,
  1182. body: null,
  1183. querystring,
  1184. };
  1185. return this.transport.request(request, options, callback);
  1186. };
  1187. /**
  1188. * Returns a progress status of current upgrade.
  1189. *
  1190. * @memberOf API-Index
  1191. *
  1192. * @param {Object} params
  1193. * @param {string} params.index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
  1194. * @param {boolean} [params.ignore_unavailable] - Whether specified concrete indices should be ignored when unavailable (missing or closed)
  1195. * @param {boolean} [params.allow_no_indices] - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
  1196. * @param {string} [params.expand_wildcards] - Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
  1197. *
  1198. * @param {Object} options - Options for {@link Transport#request}
  1199. * @param {function} callback - Callback that handles errors and response
  1200. *
  1201. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1202. */
  1203. IndicesApi.prototype.getUpgrade = function indicesGetUpgradeApi(params, options, callback) {
  1204. [params, options, callback] = normalizeArguments(params, options, callback);
  1205. let { method, body, index, ...querystring } = params;
  1206. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  1207. let path = '';
  1208. if (method == null) method = 'GET';
  1209. path = '/' + encodeURIComponent(index) + '/' + '_upgrade';
  1210. // build request object
  1211. const request = {
  1212. method,
  1213. path,
  1214. body: null,
  1215. querystring,
  1216. };
  1217. return this.transport.request(request, options, callback);
  1218. };
  1219. /**
  1220. * ROpens an index.
  1221. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/index-apis/open-index/ OpenSearch - Open Index}
  1222. *
  1223. * @memberOf API-Index
  1224. *
  1225. * @param {Object} params
  1226. * @param {string} params.index - A comma separated list of indices to open
  1227. * @param {string} [params.timeout] - Explicit operation timeout
  1228. * @param {string} [params.cluster_manager_timeout] - Explicit operation timeout for connection to cluster_manager node
  1229. * @param {boolean} [params.ignore_unavailable] - Whether specified concrete indices should be ignored when unavailable (missing or closed)
  1230. * @param {boolean} [params.allow_no_indices] - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
  1231. * @param {string} [params.expand_wildcards] - Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
  1232. * @param {string} [params.wait_for_active_shards] - Sets the number of active shards to wait for before the operation returns.
  1233. *
  1234. * @param {Object} options - Options for {@link Transport#request}
  1235. * @param {function} callback - Callback that handles errors and response
  1236. *
  1237. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1238. */
  1239. IndicesApi.prototype.open = function indicesOpenApi(params, options, callback) {
  1240. [params, options, callback] = normalizeArguments(params, options, callback);
  1241. // check required parameters
  1242. if (params.index == null) {
  1243. const err = new this[kConfigurationError]('Missing required parameter: index');
  1244. return handleError(err, callback);
  1245. }
  1246. let { method, body, index, ...querystring } = params;
  1247. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  1248. let path = '';
  1249. if (method == null) method = 'POST';
  1250. path = '/' + encodeURIComponent(index) + '/' + '_open';
  1251. // build request object
  1252. const request = {
  1253. method,
  1254. path,
  1255. body: body || '',
  1256. querystring,
  1257. };
  1258. return this.transport.request(request, options, callback);
  1259. };
  1260. /**
  1261. * Creates or updates an alias.
  1262. * <br/> See Also: {@link https://opensearch.org/docs/latest/opensearch/index-alias/ OpenSearch - Index Aliases}
  1263. *
  1264. * @memberOf API-Index
  1265. *
  1266. * @param {Object} params
  1267. * @param {string} params.index - A comma-separated list of index names the alias should point to (supports wildcards); use `_all` to perform the operation on all indices.
  1268. * @param {string} params.name - The name of the alias to be created or updated
  1269. * @param {string} [params.timeout] - Explicit timestamp for the document
  1270. * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
  1271. * @param {Object} [params.body] - The settings for the alias, such as `routing` or `filter`
  1272. *
  1273. * @param {Object} options - Options for {@link Transport#request}
  1274. * @param {function} callback - Callback that handles errors and response
  1275. *
  1276. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1277. */
  1278. IndicesApi.prototype.putAlias = function indicesPutAliasApi(params, options, callback) {
  1279. [params, options, callback] = normalizeArguments(params, options, callback);
  1280. // check required parameters
  1281. if (params.index == null) {
  1282. const err = new this[kConfigurationError]('Missing required parameter: index');
  1283. return handleError(err, callback);
  1284. }
  1285. if (params.name == null) {
  1286. const err = new this[kConfigurationError]('Missing required parameter: name');
  1287. return handleError(err, callback);
  1288. }
  1289. // check required url components
  1290. if (params.name != null && params.index == null) {
  1291. const err = new this[kConfigurationError]('Missing required parameter of the url: index');
  1292. return handleError(err, callback);
  1293. }
  1294. let { method, body, index, name, ...querystring } = params;
  1295. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  1296. let path = '';
  1297. if (index != null && name != null) {
  1298. if (method == null) method = 'PUT';
  1299. path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name);
  1300. } else {
  1301. if (method == null) method = 'PUT';
  1302. path = '/' + encodeURIComponent(index) + '/' + '_aliases' + '/' + encodeURIComponent(name);
  1303. }
  1304. // build request object
  1305. const request = {
  1306. method,
  1307. path,
  1308. body: body || '',
  1309. querystring,
  1310. };
  1311. return this.transport.request(request, options, callback);
  1312. };
  1313. /**
  1314. * Creates or updates an index template.
  1315. * <br/> See Also: {@link https://opensearch.org/docs/latest/opensearch/index-templates/ OpenSearch - Index Templates}
  1316. *
  1317. * @memberOf API-Index
  1318. *
  1319. * @param {Object} params
  1320. * @param {string} params.name - The name of the template
  1321. * @param {Object} params.body - The template definition
  1322. * @param {boolean} [params.create] - Whether the index template should only be added if new or can also replace an existing one
  1323. * @param {string} [params.cause] - User defined reason for creating/updating the index template
  1324. * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
  1325. *
  1326. * @param {Object} options - Options for {@link Transport#request}
  1327. * @param {function} callback - Callback that handles errors and response
  1328. *
  1329. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1330. */
  1331. IndicesApi.prototype.putIndexTemplate = function indicesPutIndexTemplateApi(
  1332. params,
  1333. options,
  1334. callback
  1335. ) {
  1336. [params, options, callback] = normalizeArguments(params, options, callback);
  1337. // check required parameters
  1338. if (params.name == null) {
  1339. const err = new this[kConfigurationError]('Missing required parameter: name');
  1340. return handleError(err, callback);
  1341. }
  1342. if (params.body == null) {
  1343. const err = new this[kConfigurationError]('Missing required parameter: body');
  1344. return handleError(err, callback);
  1345. }
  1346. let { method, body, name, ...querystring } = params;
  1347. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  1348. let path = '';
  1349. if (method == null) method = 'PUT';
  1350. path = '/' + '_index_template' + '/' + encodeURIComponent(name);
  1351. // build request object
  1352. const request = {
  1353. method,
  1354. path,
  1355. body: body || '',
  1356. querystring,
  1357. };
  1358. return this.transport.request(request, options, callback);
  1359. };
  1360. /**
  1361. * Updates index mappings.
  1362. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/index-apis/put-mapping/ OpenSearch - Create or Update Mapping}
  1363. *
  1364. * @memberOf API-Index
  1365. *
  1366. * @param {Object} params
  1367. * @param {string} params.index - A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices.
  1368. * @param {Object} params.body - The mapping definition
  1369. * @param {string} [params.timeout] - Explicit operation timeout
  1370. * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
  1371. * @param {boolean} [params.ignore_unavailable] - Whether specified concrete indices should be ignored when unavailable (missing or closed)
  1372. * @param {boolean} [params.allow_no_indices] - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
  1373. * @param {string} [params.expand_wildcards] - Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
  1374. * @param {boolean} [params.write_index_only] - When true, applies mappings only to the write index of an alias or data stream
  1375. *
  1376. * @param {Object} options - Options for {@link Transport#request}
  1377. * @param {function} callback - Callback that handles errors and response
  1378. *
  1379. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1380. */
  1381. IndicesApi.prototype.putMapping = function indicesPutMappingApi(params, options, callback) {
  1382. [params, options, callback] = normalizeArguments(params, options, callback);
  1383. // check required parameters
  1384. if (params.body == null) {
  1385. const err = new this[kConfigurationError]('Missing required parameter: body');
  1386. return handleError(err, callback);
  1387. }
  1388. let { method, body, index, type, ...querystring } = params;
  1389. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  1390. let path = '';
  1391. if (index != null && type != null) {
  1392. if (method == null) method = 'PUT';
  1393. path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_mapping';
  1394. } else if (index != null && type != null) {
  1395. if (method == null) method = 'PUT';
  1396. path = '/' + encodeURIComponent(index) + '/' + '_mapping' + '/' + encodeURIComponent(type);
  1397. } else if (index != null && type != null) {
  1398. if (method == null) method = 'PUT';
  1399. path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_mappings';
  1400. } else if (index != null && type != null) {
  1401. if (method == null) method = 'PUT';
  1402. path = '/' + encodeURIComponent(index) + '/' + '_mappings' + '/' + encodeURIComponent(type);
  1403. } else if (index != null) {
  1404. if (method == null) method = 'PUT';
  1405. path = '/' + encodeURIComponent(index) + '/' + '_mapping';
  1406. } else if (type != null) {
  1407. if (method == null) method = 'PUT';
  1408. path = '/' + '_mappings' + '/' + encodeURIComponent(type);
  1409. } else if (index != null) {
  1410. if (method == null) method = 'PUT';
  1411. path = '/' + encodeURIComponent(index) + '/' + '_mappings';
  1412. } else {
  1413. if (method == null) method = 'PUT';
  1414. path = '/' + '_mapping' + '/' + encodeURIComponent(type);
  1415. }
  1416. // build request object
  1417. const request = {
  1418. method,
  1419. path,
  1420. body: body || '',
  1421. querystring,
  1422. };
  1423. return this.transport.request(request, options, callback);
  1424. };
  1425. /**
  1426. * Updates the index settings.
  1427. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/index-apis/update-settings/ OpenSearch - Update Settings}
  1428. *
  1429. * @memberOf API-Index
  1430. *
  1431. * @param {Object} params
  1432. * @param {Object} params.body - The index settings to be updated
  1433. * @param {string} [params.index] - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
  1434. * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
  1435. * @param {string} [params.timeout] - Explicit operation timeout
  1436. * @param {boolean} [params.preserve_existing=false] - Whether to update existing settings. If set to `true` existing settings on an index remain unchanged
  1437. * @param {boolean} [params.ignore_unavailable] - Whether specified concrete indices should be ignored when unavailable (missing or closed)
  1438. * @param {boolean} [params.allow_no_indices] - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
  1439. * @param {string} [params.expand_wildcards] - Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
  1440. * @param {boolean} [params.flat_settings=false] - Return settings in flat format
  1441. *
  1442. * @param {Object} options - Options for {@link Transport#request}
  1443. * @param {function} callback - Callback that handles errors and response
  1444. *
  1445. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1446. */
  1447. IndicesApi.prototype.putSettings = function indicesPutSettingsApi(params, options, callback) {
  1448. [params, options, callback] = normalizeArguments(params, options, callback);
  1449. // check required parameters
  1450. if (params.body == null) {
  1451. const err = new this[kConfigurationError]('Missing required parameter: body');
  1452. return handleError(err, callback);
  1453. }
  1454. let { method, body, index, ...querystring } = params;
  1455. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  1456. let path = '';
  1457. if (index != null) {
  1458. if (method == null) method = 'PUT';
  1459. path = '/' + encodeURIComponent(index) + '/' + '_settings';
  1460. } else {
  1461. if (method == null) method = 'PUT';
  1462. path = '/' + '_settings';
  1463. }
  1464. // build request object
  1465. const request = {
  1466. method,
  1467. path,
  1468. body: body || '',
  1469. querystring,
  1470. };
  1471. return this.transport.request(request, options, callback);
  1472. };
  1473. /**
  1474. * Creates or updates an index template. (Deprecated. Use IndicesApi#putIndexTemplate instead)
  1475. *
  1476. * @memberOf API-Index
  1477. *
  1478. * @param {Object} params
  1479. * @param {string} params.name - The name of the template
  1480. * @param {Object} params.body - The template definition
  1481. * @param {number} [params.order] - The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers)
  1482. * @param {boolean} [params.create] - Whether the index template should only be added if new or can also replace an existing one
  1483. * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
  1484. *
  1485. * @param {Object} options - Options for {@link Transport#request}
  1486. * @param {function} callback - Callback that handles errors and response
  1487. *
  1488. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1489. */
  1490. IndicesApi.prototype.putTemplate = function indicesPutTemplateApi(params, options, callback) {
  1491. [params, options, callback] = normalizeArguments(params, options, callback);
  1492. // check required parameters
  1493. if (params.name == null) {
  1494. const err = new this[kConfigurationError]('Missing required parameter: name');
  1495. return handleError(err, callback);
  1496. }
  1497. if (params.body == null) {
  1498. const err = new this[kConfigurationError]('Missing required parameter: body');
  1499. return handleError(err, callback);
  1500. }
  1501. let { method, body, name, ...querystring } = params;
  1502. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  1503. let path = '';
  1504. if (method == null) method = 'PUT';
  1505. path = '/' + '_template' + '/' + encodeURIComponent(name);
  1506. // build request object
  1507. const request = {
  1508. method,
  1509. path,
  1510. body: body || '',
  1511. querystring,
  1512. };
  1513. return this.transport.request(request, options, callback);
  1514. };
  1515. /**
  1516. * Returns information about ongoing index shard recoveries.
  1517. *
  1518. * @memberOf API-Index
  1519. *
  1520. * @param {Object} params
  1521. * @param {string} [params.index] - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
  1522. * @param {boolean} [params.detailed] - Whether to display detailed information about shard recovery
  1523. * @param {boolean} [params.active_only] - Display only those recoveries that are currently on-going
  1524. *
  1525. * @param {Object} options - Options for {@link Transport#request}
  1526. * @param {function} callback - Callback that handles errors and response
  1527. *
  1528. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1529. */
  1530. IndicesApi.prototype.recovery = function indicesRecoveryApi(params, options, callback) {
  1531. [params, options, callback] = normalizeArguments(params, options, callback);
  1532. let { method, body, index, ...querystring } = params;
  1533. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  1534. let path = '';
  1535. if (index != null) {
  1536. if (method == null) method = 'GET';
  1537. path = '/' + encodeURIComponent(index) + '/' + '_recovery';
  1538. } else {
  1539. if (method == null) method = 'GET';
  1540. path = '/' + '_recovery';
  1541. }
  1542. // build request object
  1543. const request = {
  1544. method,
  1545. path,
  1546. body: null,
  1547. querystring,
  1548. };
  1549. return this.transport.request(request, options, callback);
  1550. };
  1551. /**
  1552. * Performs the refresh operation in one or more indices.
  1553. *
  1554. * @memberOf API-Index
  1555. *
  1556. * @param {Object} params
  1557. * @param {string} [params.index] - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
  1558. * @param {boolean} [params.ignore_unavailable] - Whether specified concrete indices should be ignored when unavailable (missing or closed)
  1559. * @param {boolean} [params.allow_no_indices] - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
  1560. * @param {string} [params.expand_wildcards] - Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
  1561. *
  1562. * @param {Object} options - Options for {@link Transport#request}
  1563. * @param {function} callback - Callback that handles errors and response
  1564. *
  1565. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1566. */
  1567. IndicesApi.prototype.refresh = function indicesRefreshApi(params, options, callback) {
  1568. [params, options, callback] = normalizeArguments(params, options, callback);
  1569. let { method, body, index, ...querystring } = params;
  1570. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  1571. let path = '';
  1572. if (index != null) {
  1573. if (method == null) method = body == null ? 'GET' : 'POST';
  1574. path = '/' + encodeURIComponent(index) + '/' + '_refresh';
  1575. } else {
  1576. if (method == null) method = body == null ? 'GET' : 'POST';
  1577. path = '/' + '_refresh';
  1578. }
  1579. // build request object
  1580. const request = {
  1581. method,
  1582. path,
  1583. body: body || '',
  1584. querystring,
  1585. };
  1586. return this.transport.request(request, options, callback);
  1587. };
  1588. /**
  1589. * Returns information about any matching indices, aliases, and data streams
  1590. *
  1591. * @memberOf API-Index
  1592. *
  1593. * @param {Object} params
  1594. * @param {string} [params.name] - A comma-separated list of names or wildcard expressions
  1595. * @param {string} [params.expand_wildcards=open] - Whether wildcard expressions should get expanded to open or closed indices (options: open, closed, hidden, none, all)
  1596. *
  1597. * @param {Object} options - Options for {@link Transport#request}
  1598. * @param {function} callback - Callback that handles errors and response
  1599. *
  1600. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1601. */
  1602. IndicesApi.prototype.resolveIndex = function indicesResolveIndexApi(params, options, callback) {
  1603. [params, options, callback] = normalizeArguments(params, options, callback);
  1604. // check required parameters
  1605. if (params.name == null) {
  1606. const err = new this[kConfigurationError]('Missing required parameter: name');
  1607. return handleError(err, callback);
  1608. }
  1609. let { method, body, name, ...querystring } = params;
  1610. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  1611. let path = '';
  1612. if (method == null) method = 'GET';
  1613. path = '/' + '_resolve' + '/' + 'index' + '/' + encodeURIComponent(name);
  1614. // build request object
  1615. const request = {
  1616. method,
  1617. path,
  1618. body: null,
  1619. querystring,
  1620. };
  1621. return this.transport.request(request, options, callback);
  1622. };
  1623. /**
  1624. * Updates an alias to point to a new index when the existing index is considered to be too large or too old.
  1625. * <br/> See Also: {@link https://opensearch.org/docs/latest/opensearch/data-streams/#step-5-rollover-a-data-stream OpenSearch - Rollover a data stream}
  1626. *
  1627. * @memberOf API-Index
  1628. *
  1629. * @param {Object} params
  1630. * @param {string} params.alias - The name of the alias to rollover
  1631. * @param {string} [params.new_index] - The name of the rollover index
  1632. * @param {string} [params.timeout] - Explicit operation timeout
  1633. * @param {boolean} [params.dry_run=false] - If set to true the rollover action will only be validated but not actually performed even if a condition matches.
  1634. * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
  1635. * @param {string} [params.wait_for_active_shards] - Set the number of active shards to wait for on the newly created rollover index before the operation returns.
  1636. * @param {Object} [params.body] - The conditions that needs to be met for executing rollover
  1637. *
  1638. * @param {Object} options - Options for {@link Transport#request}
  1639. * @param {function} callback - Callback that handles errors and response
  1640. *
  1641. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1642. */
  1643. IndicesApi.prototype.rollover = function indicesRolloverApi(params, options, callback) {
  1644. [params, options, callback] = normalizeArguments(params, options, callback);
  1645. // check required parameters
  1646. if (params.alias == null) {
  1647. const err = new this[kConfigurationError]('Missing required parameter: alias');
  1648. return handleError(err, callback);
  1649. }
  1650. // check required url components
  1651. if ((params.new_index != null || params.newIndex != null) && params.alias == null) {
  1652. const err = new this[kConfigurationError]('Missing required parameter of the url: alias');
  1653. return handleError(err, callback);
  1654. }
  1655. let { method, body, alias, newIndex, new_index, ...querystring } = params;
  1656. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  1657. let path = '';
  1658. if (alias != null && (new_index || newIndex) != null) {
  1659. if (method == null) method = 'POST';
  1660. path =
  1661. '/' +
  1662. encodeURIComponent(alias) +
  1663. '/' +
  1664. '_rollover' +
  1665. '/' +
  1666. encodeURIComponent(new_index || newIndex);
  1667. } else {
  1668. if (method == null) method = 'POST';
  1669. path = '/' + encodeURIComponent(alias) + '/' + '_rollover';
  1670. }
  1671. // build request object
  1672. const request = {
  1673. method,
  1674. path,
  1675. body: body || '',
  1676. querystring,
  1677. };
  1678. return this.transport.request(request, options, callback);
  1679. };
  1680. /**
  1681. * Provides low-level information about segments in a Lucene index.
  1682. *
  1683. * @memberOf API-Index
  1684. *
  1685. * @param {Object} params
  1686. * @param {string} [params.index] - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
  1687. * @param {boolean} [params.ignore_unavailable] - Whether specified concrete indices should be ignored when unavailable (missing or closed)
  1688. * @param {boolean} [params.allow_no_indices] - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
  1689. * @param {string} [params.expand_wildcards] - Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
  1690. * @param {boolean} [params.verbose] - Includes detailed memory usage by Lucene.
  1691. *
  1692. * @param {Object} options - Options for {@link Transport#request}
  1693. * @param {function} callback - Callback that handles errors and response
  1694. *
  1695. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1696. */
  1697. IndicesApi.prototype.segments = function indicesSegmentsApi(params, options, callback) {
  1698. [params, options, callback] = normalizeArguments(params, options, callback);
  1699. let { method, body, index, ...querystring } = params;
  1700. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  1701. let path = '';
  1702. if (index != null) {
  1703. if (method == null) method = 'GET';
  1704. path = '/' + encodeURIComponent(index) + '/' + '_segments';
  1705. } else {
  1706. if (method == null) method = 'GET';
  1707. path = '/' + '_segments';
  1708. }
  1709. // build request object
  1710. const request = {
  1711. method,
  1712. path,
  1713. body: null,
  1714. querystring,
  1715. };
  1716. return this.transport.request(request, options, callback);
  1717. };
  1718. /**
  1719. * Provides store information for shard copies of indices.
  1720. *
  1721. * @memberOf API-Index
  1722. *
  1723. * @param {Object} params
  1724. * @param {string} [params.index] - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
  1725. * @param {string} [params.status] - A comma-separated list of statuses used to filter on shards to get store information for (options: green, yellow, red, all)
  1726. * @param {boolean} [params.ignore_unavailable] - Whether specified concrete indices should be ignored when unavailable (missing or closed)
  1727. * @param {boolean} [params.allow_no_indices] - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
  1728. * @param {string} [params.expand_wildcards] - Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
  1729. *
  1730. * @param {Object} options - Options for {@link Transport#request}
  1731. * @param {function} callback - Callback that handles errors and response
  1732. *
  1733. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1734. */
  1735. IndicesApi.prototype.shardStores = function indicesShardStoresApi(params, options, callback) {
  1736. [params, options, callback] = normalizeArguments(params, options, callback);
  1737. let { method, body, index, ...querystring } = params;
  1738. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  1739. let path = '';
  1740. if (index != null) {
  1741. if (method == null) method = 'GET';
  1742. path = '/' + encodeURIComponent(index) + '/' + '_shard_stores';
  1743. } else {
  1744. if (method == null) method = 'GET';
  1745. path = '/' + '_shard_stores';
  1746. }
  1747. // build request object
  1748. const request = {
  1749. method,
  1750. path,
  1751. body: null,
  1752. querystring,
  1753. };
  1754. return this.transport.request(request, options, callback);
  1755. };
  1756. /**
  1757. * Allow to shrink an existing index into a new index with fewer primary shards.
  1758. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/index-apis/shrink-index/ OpenSearch - Shrink Index}
  1759. *
  1760. * @memberOf API-Index
  1761. *
  1762. * @param {Object} params
  1763. * @param {string} params.index - The name of the source index to shrink
  1764. * @param {string} params.target - The name of the target index to shrink into
  1765. * @param {boolean} [params.copy_settings] - whether or not to copy settings from the source index (defaults to false)
  1766. * @param {string} [params.timeout] - Explicit operation timeout
  1767. * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
  1768. * @param {string} [params.wait_for_active_shards] - Set the number of active shards to wait for on the shrunken index before the operation returns.
  1769. * @param {Object} [params.body] - The configuration for the target index (`settings` and `aliases`)
  1770. *
  1771. * @param {Object} options - Options for {@link Transport#request}
  1772. * @param {function} callback - Callback that handles errors and response
  1773. *
  1774. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1775. */
  1776. IndicesApi.prototype.shrink = function indicesShrinkApi(params, options, callback) {
  1777. [params, options, callback] = normalizeArguments(params, options, callback);
  1778. // check required parameters
  1779. if (params.index == null) {
  1780. const err = new this[kConfigurationError]('Missing required parameter: index');
  1781. return handleError(err, callback);
  1782. }
  1783. if (params.target == null) {
  1784. const err = new this[kConfigurationError]('Missing required parameter: target');
  1785. return handleError(err, callback);
  1786. }
  1787. // check required url components
  1788. if (params.target != null && params.index == null) {
  1789. const err = new this[kConfigurationError]('Missing required parameter of the url: index');
  1790. return handleError(err, callback);
  1791. }
  1792. let { method, body, index, target, ...querystring } = params;
  1793. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  1794. let path = '';
  1795. if (method == null) method = 'PUT';
  1796. path = '/' + encodeURIComponent(index) + '/' + '_shrink' + '/' + encodeURIComponent(target);
  1797. // build request object
  1798. const request = {
  1799. method,
  1800. path,
  1801. body: body || '',
  1802. querystring,
  1803. };
  1804. return this.transport.request(request, options, callback);
  1805. };
  1806. /**
  1807. * Simulate matching the given index name against the index templates in the system
  1808. *
  1809. * @memberOf API-Index
  1810. *
  1811. * @param {Object} params
  1812. * @param {string} params.name - The name of the index (it must be a concrete index name)
  1813. * @param {Object} [params.body] - New index template definition, which will be included in the simulation, as if it already exists in the system
  1814. * @param {boolean} [params.create] - Whether the index template we optionally defined in the body should only be dry-run added if new or can also replace an existing one
  1815. * @param {string} [params.cause] - User defined reason for dry-run creating the new template for simulation purposes
  1816. * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
  1817. *
  1818. * @param {Object} options - Options for {@link Transport#request}
  1819. * @param {function} callback - Callback that handles errors and response
  1820. *
  1821. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1822. */
  1823. IndicesApi.prototype.simulateIndexTemplate = function indicesSimulateIndexTemplateApi(
  1824. params,
  1825. options,
  1826. callback
  1827. ) {
  1828. [params, options, callback] = normalizeArguments(params, options, callback);
  1829. // check required parameters
  1830. if (params.name == null) {
  1831. const err = new this[kConfigurationError]('Missing required parameter: name');
  1832. return handleError(err, callback);
  1833. }
  1834. let { method, body, name, ...querystring } = params;
  1835. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  1836. let path = '';
  1837. if (method == null) method = 'POST';
  1838. path = '/' + '_index_template' + '/' + '_simulate_index' + '/' + encodeURIComponent(name);
  1839. // build request object
  1840. const request = {
  1841. method,
  1842. path,
  1843. body: body || '',
  1844. querystring,
  1845. };
  1846. return this.transport.request(request, options, callback);
  1847. };
  1848. /**
  1849. * Simulate resolving the given template name or body (Deprecated. Use IndicesApi#simulateIndexTemplate instead)
  1850. *
  1851. * @memberOf API-Index
  1852. *
  1853. * @param {Object} params
  1854. * @param {string} [params.name] - The name of the index template
  1855. * @param {boolean} [params.create] - Whether the index template we optionally defined in the body should only be dry-run added if new or can also replace an existing one
  1856. * @param {string} [params.cause] - User defined reason for dry-run creating the new template for simulation purposes
  1857. * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
  1858. * @param {Object} [params.body] - New index template definition to be simulated, if no index template name is specified
  1859. *
  1860. * @param {Object} options - Options for {@link Transport#request}
  1861. * @param {function} callback - Callback that handles errors and response
  1862. *
  1863. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1864. */
  1865. IndicesApi.prototype.simulateTemplate = function indicesSimulateTemplateApi(
  1866. params,
  1867. options,
  1868. callback
  1869. ) {
  1870. [params, options, callback] = normalizeArguments(params, options, callback);
  1871. let { method, body, name, ...querystring } = params;
  1872. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  1873. let path = '';
  1874. if (name != null) {
  1875. if (method == null) method = 'POST';
  1876. path = '/' + '_index_template' + '/' + '_simulate' + '/' + encodeURIComponent(name);
  1877. } else {
  1878. if (method == null) method = 'POST';
  1879. path = '/' + '_index_template' + '/' + '_simulate';
  1880. }
  1881. // build request object
  1882. const request = {
  1883. method,
  1884. path,
  1885. body: body || '',
  1886. querystring,
  1887. };
  1888. return this.transport.request(request, options, callback);
  1889. };
  1890. /**
  1891. * Allows you to split an existing index into a new index with more primary shards.
  1892. * <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/index-apis/split/ OpenSearch - Split Index}
  1893. *
  1894. * @memberOf API-Index
  1895. *
  1896. * @param {Object} params
  1897. * @param {string} params.index - The name of the source index to split
  1898. * @param {string} params.target - The name of the target index to split into
  1899. * @param {boolean} [params.copy_settings] - whether or not to copy settings from the source index (defaults to false)
  1900. * @param {string} [params.timeout] - Explicit operation timeout
  1901. * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
  1902. * @param {string} [params.wait_for_active_shards] - Set the number of active shards to wait for on the shrunken index before the operation returns.
  1903. * @param {Object} [params.body] - The configuration for the target index (`settings` and `aliases`)
  1904. *
  1905. * @param {Object} options - Options for {@link Transport#request}
  1906. * @param {function} callback - Callback that handles errors and response
  1907. *
  1908. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1909. */
  1910. IndicesApi.prototype.split = function indicesSplitApi(params, options, callback) {
  1911. [params, options, callback] = normalizeArguments(params, options, callback);
  1912. // check required parameters
  1913. if (params.index == null) {
  1914. const err = new this[kConfigurationError]('Missing required parameter: index');
  1915. return handleError(err, callback);
  1916. }
  1917. if (params.target == null) {
  1918. const err = new this[kConfigurationError]('Missing required parameter: target');
  1919. return handleError(err, callback);
  1920. }
  1921. // check required url components
  1922. if (params.target != null && params.index == null) {
  1923. const err = new this[kConfigurationError]('Missing required parameter of the url: index');
  1924. return handleError(err, callback);
  1925. }
  1926. let { method, body, index, target, ...querystring } = params;
  1927. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  1928. let path = '';
  1929. if (method == null) method = 'PUT';
  1930. path = '/' + encodeURIComponent(index) + '/' + '_split' + '/' + encodeURIComponent(target);
  1931. // build request object
  1932. const request = {
  1933. method,
  1934. path,
  1935. body: body || '',
  1936. querystring,
  1937. };
  1938. return this.transport.request(request, options, callback);
  1939. };
  1940. /**
  1941. * Provides statistics on operations happening in an index.
  1942. *
  1943. * @memberOf API-Index
  1944. *
  1945. * @param {Object} params
  1946. * @param {string} [params.metric] - Limit the information returned the specific metrics. (options: _all, completion, docs, fielddata, query_cache, flush, get, indexing, merge, request_cache, refresh, search, segments, store, warmer, suggest)
  1947. * @param {string} [params.index] - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
  1948. * @param {string} [params.completion_fields] - A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards)
  1949. * @param {string} [params.fielddata_fields] - A comma-separated list of fields for `fielddata` index metric (supports wildcards)
  1950. * @param {string} [params.fields] - A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards)
  1951. * @param {string} [params.groups] - A comma-separated list of search groups for `search` index metric
  1952. * @param {string} [params.level] - Return stats aggregated at cluster, index or shard level (options: cluster, indices, shards)
  1953. * @param {string} [params.types] - A comma-separated list of document types for the `indexing` index metric
  1954. * @param {boolean} [params.include_segment_file_sizes] - Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested)
  1955. * @param {boolean} [params.include_unloaded_segments] - If set to true segment stats will include stats for segments that are not currently loaded into memory
  1956. * @param {string} [params.expand_wildcards] - Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
  1957. * @param {boolean} [params.forbid_closed_indices] - If set to false stats will also collected from closed indices if explicitly specified or if expand_wildcards expands to closed indices
  1958. *
  1959. * @param {Object} options - Options for {@link Transport#request}
  1960. * @param {function} callback - Callback that handles errors and response
  1961. *
  1962. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1963. */
  1964. IndicesApi.prototype.stats = function indicesStatsApi(params, options, callback) {
  1965. [params, options, callback] = normalizeArguments(params, options, callback);
  1966. let { method, body, metric, index, ...querystring } = params;
  1967. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  1968. let path = '';
  1969. if (index != null && metric != null) {
  1970. if (method == null) method = 'GET';
  1971. path = '/' + encodeURIComponent(index) + '/' + '_stats' + '/' + encodeURIComponent(metric);
  1972. } else if (metric != null) {
  1973. if (method == null) method = 'GET';
  1974. path = '/' + '_stats' + '/' + encodeURIComponent(metric);
  1975. } else if (index != null) {
  1976. if (method == null) method = 'GET';
  1977. path = '/' + encodeURIComponent(index) + '/' + '_stats';
  1978. } else {
  1979. if (method == null) method = 'GET';
  1980. path = '/' + '_stats';
  1981. }
  1982. // build request object
  1983. const request = {
  1984. method,
  1985. path,
  1986. body: null,
  1987. querystring,
  1988. };
  1989. return this.transport.request(request, options, callback);
  1990. };
  1991. /**
  1992. * Update an alias.
  1993. * <br/> See Also: {@link https://opensearch.org/docs/latest/opensearch/index-alias/ OpenSearch - Index Aliases}
  1994. *
  1995. * @memberOf API-Index
  1996. *
  1997. * @param {Object} params
  1998. * @param {Object} params.body - The definition of `actions` to perform
  1999. * @param {string} [params.timeout] - Request timeout
  2000. * @param {string} [params.cluster_manager_timeout] - Specify timeout for connection to cluster_manager
  2001. *
  2002. * @param {Object} options - Options for {@link Transport#request}
  2003. * @param {function} callback - Callback that handles errors and response
  2004. *
  2005. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  2006. */
  2007. IndicesApi.prototype.updateAliases = function indicesUpdateAliasesApi(params, options, callback) {
  2008. [params, options, callback] = normalizeArguments(params, options, callback);
  2009. // check required parameters
  2010. if (params.body == null) {
  2011. const err = new this[kConfigurationError]('Missing required parameter: body');
  2012. return handleError(err, callback);
  2013. }
  2014. let { method, body, ...querystring } = params;
  2015. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  2016. let path = '';
  2017. if (method == null) method = 'POST';
  2018. path = '/' + '_aliases';
  2019. // build request object
  2020. const request = {
  2021. method,
  2022. path,
  2023. body: body || '',
  2024. querystring,
  2025. };
  2026. return this.transport.request(request, options, callback);
  2027. };
  2028. /**
  2029. * Upgrades to the current version of Lucene.
  2030. *
  2031. * @memberOf API-Index
  2032. *
  2033. * @param {Object} params
  2034. * @param {string} [params.index] - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
  2035. * @param {boolean} [params.allow_no_indices] - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
  2036. * @param {string} [params.expand_wildcards] - Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
  2037. * @param {boolean} [params.ignore_unavailable] - Whether specified concrete indices should be ignored when unavailable (missing or closed)
  2038. * @param {boolean} [params.wait_for_completion=false] - Specify whether the request should block until the all segments are upgraded
  2039. * @param {boolean} [params.only_ancient_segments] - If true, only ancient (an older Lucene major release) segments will be upgraded
  2040. *
  2041. * @param {Object} options - Options for {@link Transport#request}
  2042. * @param {function} callback - Callback that handles errors and response
  2043. *
  2044. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  2045. */
  2046. IndicesApi.prototype.upgrade = function indicesUpgradeApi(params, options, callback) {
  2047. [params, options, callback] = normalizeArguments(params, options, callback);
  2048. let { method, body, index, ...querystring } = params;
  2049. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  2050. let path = '';
  2051. if (method == null) method = 'POST';
  2052. path = '/' + encodeURIComponent(index) + '/' + '_upgrade';
  2053. // build request object
  2054. const request = {
  2055. method,
  2056. path,
  2057. body: body || '',
  2058. querystring,
  2059. };
  2060. return this.transport.request(request, options, callback);
  2061. };
  2062. /**
  2063. * Allows a user to validate a potentially expensive query without executing it.
  2064. *
  2065. * @memberOf API-Index
  2066. *
  2067. * @param {Object} params
  2068. * @param {string} params.index - A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices
  2069. * @param {boolean} [params.explain] - Return detailed information about the error
  2070. * @param {boolean} [params.ignore_unavailable] - Whether specified concrete indices should be ignored when unavailable (missing or closed)
  2071. * @param {boolean} [params.allow_no_indices] - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
  2072. * @param {string} [params.expand_wildcards] - Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
  2073. * @param {string} [params.q] - Query in the Lucene query string syntax
  2074. * @param {string} [params.analyzer] - The analyzer to use for the query string
  2075. * @param {boolean} [params.analyze_wildcard=false] - Specify whether wildcard and prefix queries should be analyzed
  2076. * @param {string} [params.default_operator=OR] - The default operator for query string query (options: AND, OR)
  2077. * @param {string} [params.df] - The field to use as default where no field prefix is given in the query string
  2078. * @param {boolean} [params.lenient] - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
  2079. * @param {boolean} [params.rewrite] - Provide a more detailed explanation showing the actual Lucene query that will be executed.
  2080. * @param {boolean} [params.all_shards] - Execute validation on all shards instead of one random shard per index
  2081. * @param {Object} [params.body] - The query definition specified with the Query DSL
  2082. *
  2083. * @param {Object} options - Options for {@link Transport#request}
  2084. * @param {function} callback - Callback that handles errors and response
  2085. *
  2086. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  2087. */
  2088. IndicesApi.prototype.validateQuery = function indicesValidateQueryApi(params, options, callback) {
  2089. [params, options, callback] = normalizeArguments(params, options, callback);
  2090. // check required url components
  2091. if (params.type != null && params.index == null) {
  2092. const err = new this[kConfigurationError]('Missing required parameter of the url: index');
  2093. return handleError(err, callback);
  2094. }
  2095. let { method, body, index, type, ...querystring } = params;
  2096. querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring);
  2097. let path = '';
  2098. if (index != null && type != null) {
  2099. if (method == null) method = body == null ? 'GET' : 'POST';
  2100. path =
  2101. '/' +
  2102. encodeURIComponent(index) +
  2103. '/' +
  2104. encodeURIComponent(type) +
  2105. '/' +
  2106. '_validate' +
  2107. '/' +
  2108. 'query';
  2109. } else if (index != null) {
  2110. if (method == null) method = body == null ? 'GET' : 'POST';
  2111. path = '/' + encodeURIComponent(index) + '/' + '_validate' + '/' + 'query';
  2112. } else {
  2113. if (method == null) method = body == null ? 'GET' : 'POST';
  2114. path = '/' + '_validate' + '/' + 'query';
  2115. }
  2116. // build request object
  2117. const request = {
  2118. method,
  2119. path,
  2120. body: body || '',
  2121. querystring,
  2122. };
  2123. return this.transport.request(request, options, callback);
  2124. };
  2125. Object.defineProperties(IndicesApi.prototype, {
  2126. add_block: {
  2127. get() {
  2128. return this.addBlock;
  2129. },
  2130. },
  2131. clear_cache: {
  2132. get() {
  2133. return this.clearCache;
  2134. },
  2135. },
  2136. delete_alias: {
  2137. get() {
  2138. return this.deleteAlias;
  2139. },
  2140. },
  2141. delete_index_template: {
  2142. get() {
  2143. return this.deleteIndexTemplate;
  2144. },
  2145. },
  2146. delete_template: {
  2147. get() {
  2148. return this.deleteTemplate;
  2149. },
  2150. },
  2151. disk_usage: {
  2152. get() {
  2153. return this.diskUsage;
  2154. },
  2155. },
  2156. exists_alias: {
  2157. get() {
  2158. return this.existsAlias;
  2159. },
  2160. },
  2161. exists_index_template: {
  2162. get() {
  2163. return this.existsIndexTemplate;
  2164. },
  2165. },
  2166. exists_template: {
  2167. get() {
  2168. return this.existsTemplate;
  2169. },
  2170. },
  2171. field_usage_stats: {
  2172. get() {
  2173. return this.fieldUsageStats;
  2174. },
  2175. },
  2176. get_alias: {
  2177. get() {
  2178. return this.getAlias;
  2179. },
  2180. },
  2181. get_field_mapping: {
  2182. get() {
  2183. return this.getFieldMapping;
  2184. },
  2185. },
  2186. get_index_template: {
  2187. get() {
  2188. return this.getIndexTemplate;
  2189. },
  2190. },
  2191. get_mapping: {
  2192. get() {
  2193. return this.getMapping;
  2194. },
  2195. },
  2196. get_settings: {
  2197. get() {
  2198. return this.getSettings;
  2199. },
  2200. },
  2201. get_template: {
  2202. get() {
  2203. return this.getTemplate;
  2204. },
  2205. },
  2206. get_upgrade: {
  2207. get() {
  2208. return this.getUpgrade;
  2209. },
  2210. },
  2211. put_alias: {
  2212. get() {
  2213. return this.putAlias;
  2214. },
  2215. },
  2216. put_index_template: {
  2217. get() {
  2218. return this.putIndexTemplate;
  2219. },
  2220. },
  2221. put_mapping: {
  2222. get() {
  2223. return this.putMapping;
  2224. },
  2225. },
  2226. put_settings: {
  2227. get() {
  2228. return this.putSettings;
  2229. },
  2230. },
  2231. put_template: {
  2232. get() {
  2233. return this.putTemplate;
  2234. },
  2235. },
  2236. resolve_index: {
  2237. get() {
  2238. return this.resolveIndex;
  2239. },
  2240. },
  2241. shard_stores: {
  2242. get() {
  2243. return this.shardStores;
  2244. },
  2245. },
  2246. simulate_index_template: {
  2247. get() {
  2248. return this.simulateIndexTemplate;
  2249. },
  2250. },
  2251. simulate_template: {
  2252. get() {
  2253. return this.simulateTemplate;
  2254. },
  2255. },
  2256. update_aliases: {
  2257. get() {
  2258. return this.updateAliases;
  2259. },
  2260. },
  2261. validate_query: {
  2262. get() {
  2263. return this.validateQuery;
  2264. },
  2265. },
  2266. });
  2267. module.exports = IndicesApi;